Java java.net URL fields, constructors, methods, implement or subclass

Example usage for Java java.net URL fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.net URL.

The text is from its open source code.

Field

Stringhost
The host name to connect to.
inthashCode
Stringhost
inthashCode

Constructor

URL(String spec)
Creates a URL object from the String representation.
URL(String protocol, String host, int port, String file)
Creates a URL object from the specified protocol , host , port number, and file .

host can be expressed as a host name or a literal IP address.

URL(String protocol, String host, String file)
Creates a URL from the specified protocol name, host name, and file name.
URL(URL context, String spec, URLStreamHandler handler)
Creates a URL by parsing the given spec with the specified handler within a specified context.
URL(URL context, String spec)
Creates a URL by parsing the given spec within a specified context.

Method

booleanequals(Object obj)
Compares this URL for equality with another object.

If the given object is not a URL then this method immediately returns false .

Two URL objects are equal if they have the same protocol, reference equivalent hosts, have the same port number on the host, and the same file and fragment of the file.

Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.

Since hosts comparison requires name resolution, this operation is a blocking operation.

StringgetAuthority()
Gets the authority part of this URL .
ClassgetClass()
Returns the runtime class of this Object .
ObjectgetContent()
Gets the contents of this URL.
ObjectgetContent(Class[] classes)
Gets the contents of this URL.
intgetDefaultPort()
Gets the default port number of the protocol associated with this URL .
StringgetFile()
Gets the file name of this URL .
StringgetHost()
Gets the host name of this URL , if applicable.
StringgetPath()
Gets the path part of this URL .
intgetPort()
Gets the port number of this URL .
StringgetProtocol()
Gets the protocol name of this URL .
StringgetQuery()
Gets the query part of this URL .
StringgetRef()
Gets the anchor (also known as the "reference") of this URL .
StringgetUserInfo()
Gets the userInfo part of this URL .
URLConnectionopenConnection()
Returns a java.net.URLConnection URLConnection instance that represents a connection to the remote object referred to by the URL .
URLConnectionopenConnection(Proxy proxy)
Same as #openConnection() , except that the connection will be made through the specified proxy; Protocol handlers that do not support proxying will ignore the proxy parameter and make a normal connection.
InputStreamopenStream()
Opens a connection to this URL and returns an InputStream for reading from that connection.
booleansameFile(URL other)
Compares two URLs, excluding the fragment component.

Returns true if this URL and the other argument are equal without taking the fragment component into consideration.

voidsetURLStreamHandlerFactory(URLStreamHandlerFactory fac)
Sets an application's URLStreamHandlerFactory .
StringtoExternalForm()
Constructs a string representation of this URL .
StringtoLowerCase(String protocol)
Returns the protocol in lower case.
StringtoString()
Constructs a string representation of this URL .
URItoURI()
Returns a java.net.URI equivalent to this URL.