All About Class URL in Java

Class URL represents a uniform resource locator-a pointer to a resource on the world wide web.A resource can be sometimes as simple as a file or a directory or it can be reference to a more complicated object,such as a query to a database or to a search engine.

The class structure of URL is given as:

public final class java.net.URL extends java.lang.Object{
//constructors
public URL();//creates a URL object from the String representation.This constructor is equivalent 
//to a call to the two argument constructor with null first arguments.Throws MalformedURLException
//if the string specifies an Unknown protocol.
public URL(String protocol,String host,int port,String file);//Creates an URL from the specified 
//protocol,host,port number and file. Throws MalformedURLException if the string specifies
//an Unknown protocol.
public URL(String protocol,String host,String file);//Creates an absolute URL from the specified
//protocol,host and file. Throws MalformedURLException if the string specifies
//an Unknown protocol.
public URL(URL context,String spec);//Creates a URL by parsing the String specification within a 
//specific context.If the context argument is not null and teh spec argument is a particular URL
//specification,then any of the Strings missing components are inherited from the context argument.
//throws  MalformedURLException  if no protocol is specified or an unknown protocol is found.
//Methods
public boolean equals(Object obj);
public final Object getContext();
public String getFile();
public String getHost();
public int getPort();
public String getProtocol();
public String getRef();
public int hashCode();
public URLConnection openConnection();
public final InputStream openStream();
public boolean sameFile(URL other);
public static void setURLStreamHandlerFactory(URLStreamHandlerFactory fac);
public String toExternalForm();
public String toString();}
 
All About Class URL in Java All About Class URL in Java Reviewed by Animesh Chatterjee on October 17, 2018 Rating: 5

No comments:

Powered by Blogger.