IT. Expert System.

Android Reference

URL


java.net

Class URL

    • Constructor Detail

      • URL

        public URL(URL context,
           String spec)
            throws MalformedURLException
        Creates a new URL by resolving spec relative to context.
        Parameters:
        context - the URL to which spec is relative, or null for no context in which case spec must be an absolute URL.
        Throws:
        MalformedURLException - if spec could not be parsed as a URL or has an unsupported protocol.
      • URL

        public URL(URL context,
           String spec,
           URLStreamHandler handler)
            throws MalformedURLException
        Creates a new URL by resolving spec relative to context.
        Parameters:
        context - the URL to which spec is relative, or null for no context in which case spec must be an absolute URL.
        handler - the stream handler for this URL, or null for the protocol's default stream handler.
        Throws:
        MalformedURLException - if the given string spec could not be parsed as a URL or an invalid protocol has been found.
      • URL

        public URL(String protocol,
           String host,
           String file)
            throws MalformedURLException
        Creates a new URL of the given component parts. The URL uses the protocol's default port.
        Throws:
        MalformedURLException - if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
      • URL

        public URL(String protocol,
           String host,
           int port,
           String file)
            throws MalformedURLException
        Creates a new URL of the given component parts. The URL uses the protocol's default port.
        Parameters:
        host - the host name or IP address of the new URL.
        port - the port, or -1 for the protocol's default port.
        file - the name of the resource.
        Throws:
        MalformedURLException - if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
      • URL

        public URL(String protocol,
           String host,
           int port,
           String file,
           URLStreamHandler handler)
            throws MalformedURLException
        Creates a new URL of the given component parts. The URL uses the protocol's default port.
        Parameters:
        host - the host name or IP address of the new URL.
        port - the port, or -1 for the protocol's default port.
        file - the name of the resource.
        handler - the stream handler for this URL, or null for the protocol's default stream handler.
        Throws:
        MalformedURLException - if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
    • Method Detail

      • setURLStreamHandlerFactory

        public static void setURLStreamHandlerFactory(URLStreamHandlerFactory factory)
        Sets the stream handler factory for this VM.
        Throws:
        Error - if a URLStreamHandlerFactory has already been installed for the current VM.
      • set

        protected void set(String protocol,
               String host,
               int port,
               String file,
               String ref)
        Sets the properties of this URL using the provided arguments. Only a URLStreamHandler can use this method to set fields of the existing URL instance. A URL is generally constant.
      • equals

        public boolean equals(Object o)
        Returns true if this URL equals o. URLs are equal if they have the same protocol, host, port, file, and reference.

        Network I/O Warning

        Some implementations of URL.equals() resolve host names over the network. This is problematic:

        • The network may be slow. Many classes, including core collections like Map and Set expect that equals and hashCode will return quickly. By violating this assumption, this method posed potential performance problems.
        • Equal IP addresses do not imply equal content. Virtual hosting permits unrelated sites to share an IP address. This method could report two otherwise unrelated URLs to be equal because they're hosted on the same server.
        • The network many not be available. Two URLs could be equal when a network is available and unequal otherwise.
        • The network may change. The IP address for a given host name varies by network and over time. This is problematic for mobile devices. Two URLs could be equal on some networks and unequal on others.

        This problem is fixed in Android 4.0 (Ice Cream Sandwich). In that release, URLs are only equal if their host names are equal (ignoring case).

        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare this instance with.
        Returns:
        true if the specified object is equal to this Object; false otherwise.
        See Also:
        Object.hashCode()
      • sameFile

        public boolean sameFile(URL otherURL)
        Returns true if this URL refers to the same resource as otherURL. All URL components except the reference field are compared.
      • hashCode

        public int hashCode()
        Description copied from class: Object
        Returns an integer hash code for this object. By contract, any two objects for which Object.equals(java.lang.Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

        Note that hash values must not change over time unless information used in equals comparisons also changes.

        See Writing a correct hashCode method if you intend implementing your own hashCode method.

        Overrides:
        hashCode in class Object
        Returns:
        this object's hash code.
        See Also:
        Object.equals(java.lang.Object)
      • getContent

        public final Object getContent()
                                throws IOException
        Returns the content of the resource which is referred by this URL. By default this returns an InputStream, or null if the content type of the response is unknown.
        Throws:
        IOException
      • openConnection

        public URLConnection openConnection()
                                     throws IOException
        Returns a new connection to the resource referred to by this URL.
        Throws:
        IOException - if an error occurs while opening the connection.
      • openConnection

        public URLConnection openConnection(Proxy proxy)
                                     throws IOException
        Returns a new connection to the resource referred to by this URL.
        Parameters:
        proxy - the proxy through which the connection will be established.
        Throws:
        IOException - if an I/O error occurs while opening the connection.
        IllegalArgumentException - if the argument proxy is null or of is an invalid type.
        UnsupportedOperationException - if the protocol handler does not support opening connections through proxies.
      • toString

        public String toString()
        Returns a string containing a concise, human-readable representation of this URL. The returned string is the same as the result of the method toExternalForm().
        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • toExternalForm

        public String toExternalForm()
        Returns a string containing a concise, human-readable representation of this URL.
      • getEffectivePort

        public int getEffectivePort()
      • getProtocol

        public String getProtocol()
        Returns the protocol of this URL like "http" or "file". This is also known as the scheme. The returned string is lower case.
      • getAuthority

        public String getAuthority()
        Returns the authority part of this URL, or null if this URL has no authority.
      • getUserInfo

        public String getUserInfo()
        Returns the user info of this URL, or null if this URL has no user info.
      • getHost

        public String getHost()
        Returns the host name or IP address of this URL.
      • getPort

        public int getPort()
        Returns the port number of this URL or -1 if this URL has no explicit port.

        If this URL has no explicit port, connections opened using this URL will use its default port.

      • getDefaultPort

        public int getDefaultPort()
        Returns the default port number of the protocol used by this URL. If no default port is defined by the protocol or the URLStreamHandler, -1 will be returned.
        See Also:
        URLStreamHandler.getDefaultPort()
      • getFile

        public String getFile()
        Returns the file of this URL.
      • getPath

        public String getPath()
        Returns the path part of this URL.
      • getQuery

        public String getQuery()
        Returns the query part of this URL, or null if this URL has no query.
      • getRef

        public String getRef()
        Returns the value of the reference part of this URL, or null if this URL has no reference part. This is also known as the fragment.
      • set

        protected void set(String protocol,
               String host,
               int port,
               String authority,
               String userInfo,
               String path,
               String query,
               String ref)
        Sets the properties of this URL using the provided arguments. Only a URLStreamHandler can use this method to set fields of the existing URL instance. A URL is generally constant.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 16038 / . Delta: 0.03251 с