< prev index next >

src/java.base/share/classes/java/net/URL.java

Print this page
imported patch classloader-cleanup


1009     public String toString() {
1010         return toExternalForm();
1011     }
1012 
1013     /**
1014      * Constructs a string representation of this {@code URL}. The
1015      * string is created by calling the {@code toExternalForm}
1016      * method of the stream protocol handler for this object.
1017      *
1018      * @return  a string representation of this object.
1019      * @see     java.net.URL#URL(java.lang.String, java.lang.String,
1020      *                  int, java.lang.String)
1021      * @see     java.net.URLStreamHandler#toExternalForm(java.net.URL)
1022      */
1023     public String toExternalForm() {
1024         return handler.toExternalForm(this);
1025     }
1026 
1027     /**
1028      * Returns a {@link java.net.URI} equivalent to this URL.
1029      * This method functions in the same way as {@code new URI (this.toString())}.
1030      * <p>Note, any URL instance that complies with RFC 2396 can be converted
1031      * to a URI. However, some URLs that are not strictly in compliance
1032      * can not be converted to a URI.
1033      *
1034      * @exception URISyntaxException if this URL is not formatted strictly according to
1035      *            RFC2396 and cannot be converted to a URI.
1036      *
1037      * @return    a URI instance equivalent to this URL.
1038      * @since 1.5
1039      */
1040     public URI toURI() throws URISyntaxException {
1041         return new URI (toString());
1042     }
1043 
1044     /**
1045      * Returns a {@link java.net.URLConnection URLConnection} instance that
1046      * represents a connection to the remote object referred to by the
1047      * {@code URL}.
1048      *
1049      * <P>A new instance of {@linkplain java.net.URLConnection URLConnection} is
1050      * created every time when invoking the
1051      * {@linkplain java.net.URLStreamHandler#openConnection(URL)
1052      * URLStreamHandler.openConnection(URL)} method of the protocol handler for
1053      * this URL.</P>
1054      *
1055      * <P>It should be noted that a URLConnection instance does not establish
1056      * the actual network connection on creation. This will happen only when
1057      * calling {@linkplain java.net.URLConnection#connect() URLConnection.connect()}.</P>
1058      *
1059      * <P>If for the URL's protocol (such as HTTP or JAR), there
1060      * exists a public, specialized URLConnection subclass belonging
1061      * to one of the following packages or one of their subpackages:




1009     public String toString() {
1010         return toExternalForm();
1011     }
1012 
1013     /**
1014      * Constructs a string representation of this {@code URL}. The
1015      * string is created by calling the {@code toExternalForm}
1016      * method of the stream protocol handler for this object.
1017      *
1018      * @return  a string representation of this object.
1019      * @see     java.net.URL#URL(java.lang.String, java.lang.String,
1020      *                  int, java.lang.String)
1021      * @see     java.net.URLStreamHandler#toExternalForm(java.net.URL)
1022      */
1023     public String toExternalForm() {
1024         return handler.toExternalForm(this);
1025     }
1026 
1027     /**
1028      * Returns a {@link java.net.URI} equivalent to this URL.
1029      * This method functions in the same way as {@code new URI(this.toString())}.
1030      * <p>Note, any URL instance that complies with RFC 2396 can be converted
1031      * to a URI. However, some URLs that are not strictly in compliance
1032      * can not be converted to a URI.
1033      *
1034      * @exception URISyntaxException if this URL is not formatted strictly according to
1035      *            RFC2396 and cannot be converted to a URI.
1036      *
1037      * @return    a URI instance equivalent to this URL.
1038      * @since 1.5
1039      */
1040     public URI toURI() throws URISyntaxException {
1041         return new URI(toString());
1042     }
1043 
1044     /**
1045      * Returns a {@link java.net.URLConnection URLConnection} instance that
1046      * represents a connection to the remote object referred to by the
1047      * {@code URL}.
1048      *
1049      * <P>A new instance of {@linkplain java.net.URLConnection URLConnection} is
1050      * created every time when invoking the
1051      * {@linkplain java.net.URLStreamHandler#openConnection(URL)
1052      * URLStreamHandler.openConnection(URL)} method of the protocol handler for
1053      * this URL.</P>
1054      *
1055      * <P>It should be noted that a URLConnection instance does not establish
1056      * the actual network connection on creation. This will happen only when
1057      * calling {@linkplain java.net.URLConnection#connect() URLConnection.connect()}.</P>
1058      *
1059      * <P>If for the URL's protocol (such as HTTP or JAR), there
1060      * exists a public, specialized URLConnection subclass belonging
1061      * to one of the following packages or one of their subpackages:


< prev index next >