992 * string is created by calling the {@code toExternalForm}
993 * method of the stream protocol handler for this object.
994 *
995 * @return a string representation of this object.
996 * @see java.net.URL#URL(java.lang.String, java.lang.String,
997 * int, java.lang.String)
998 * @see java.net.URLStreamHandler#toExternalForm(java.net.URL)
999 */
1000 public String toExternalForm() {
1001 return handler.toExternalForm(this);
1002 }
1003
1004 /**
1005 * Returns a {@link java.net.URI} equivalent to this URL.
1006 * This method functions in the same way as {@code new URI (this.toString())}.
1007 * <p>Note, any URL instance that complies with RFC 2396 can be converted
1008 * to a URI. However, some URLs that are not strictly in compliance
1009 * can not be converted to a URI.
1010 *
1011 * @exception URISyntaxException if this URL is not formatted strictly according to
1012 * to RFC2396 and cannot be converted to a URI.
1013 *
1014 * @return a URI instance equivalent to this URL.
1015 * @since 1.5
1016 */
1017 public URI toURI() throws URISyntaxException {
1018 return new URI (toString());
1019 }
1020
1021 /**
1022 * Returns a {@link java.net.URLConnection URLConnection} instance that
1023 * represents a connection to the remote object referred to by the
1024 * {@code URL}.
1025 *
1026 * <P>A new instance of {@linkplain java.net.URLConnection URLConnection} is
1027 * created every time when invoking the
1028 * {@linkplain java.net.URLStreamHandler#openConnection(URL)
1029 * URLStreamHandler.openConnection(URL)} method of the protocol handler for
1030 * this URL.</P>
1031 *
1032 * <P>It should be noted that a URLConnection instance does not establish
1037 * exists a public, specialized URLConnection subclass belonging
1038 * to one of the following packages or one of their subpackages:
1039 * java.lang, java.io, java.util, java.net, the connection
1040 * returned will be of that subclass. For example, for HTTP an
1041 * HttpURLConnection will be returned, and for JAR a
1042 * JarURLConnection will be returned.</P>
1043 *
1044 * @return a {@link java.net.URLConnection URLConnection} linking
1045 * to the URL.
1046 * @exception IOException if an I/O exception occurs.
1047 * @see java.net.URL#URL(java.lang.String, java.lang.String,
1048 * int, java.lang.String)
1049 */
1050 public URLConnection openConnection() throws java.io.IOException {
1051 return handler.openConnection(this);
1052 }
1053
1054 /**
1055 * Same as {@link #openConnection()}, except that the connection will be
1056 * made through the specified proxy; Protocol handlers that do not
1057 * support proxing will ignore the proxy parameter and make a
1058 * normal connection.
1059 *
1060 * Invoking this method preempts the system's default
1061 * {@link java.net.ProxySelector ProxySelector} settings.
1062 *
1063 * @param proxy the Proxy through which this connection
1064 * will be made. If direct connection is desired,
1065 * Proxy.NO_PROXY should be specified.
1066 * @return a {@code URLConnection} to the URL.
1067 * @exception IOException if an I/O exception occurs.
1068 * @exception SecurityException if a security manager is present
1069 * and the caller doesn't have permission to connect
1070 * to the proxy.
1071 * @exception IllegalArgumentException will be thrown if proxy is null,
1072 * or proxy has the wrong type
1073 * @exception UnsupportedOperationException if the subclass that
1074 * implements the protocol handler doesn't support
1075 * this method.
1076 * @see java.net.URL#URL(java.lang.String, java.lang.String,
1077 * int, java.lang.String)
|
992 * string is created by calling the {@code toExternalForm}
993 * method of the stream protocol handler for this object.
994 *
995 * @return a string representation of this object.
996 * @see java.net.URL#URL(java.lang.String, java.lang.String,
997 * int, java.lang.String)
998 * @see java.net.URLStreamHandler#toExternalForm(java.net.URL)
999 */
1000 public String toExternalForm() {
1001 return handler.toExternalForm(this);
1002 }
1003
1004 /**
1005 * Returns a {@link java.net.URI} equivalent to this URL.
1006 * This method functions in the same way as {@code new URI (this.toString())}.
1007 * <p>Note, any URL instance that complies with RFC 2396 can be converted
1008 * to a URI. However, some URLs that are not strictly in compliance
1009 * can not be converted to a URI.
1010 *
1011 * @exception URISyntaxException if this URL is not formatted strictly according to
1012 * RFC2396 and cannot be converted to a URI.
1013 *
1014 * @return a URI instance equivalent to this URL.
1015 * @since 1.5
1016 */
1017 public URI toURI() throws URISyntaxException {
1018 return new URI (toString());
1019 }
1020
1021 /**
1022 * Returns a {@link java.net.URLConnection URLConnection} instance that
1023 * represents a connection to the remote object referred to by the
1024 * {@code URL}.
1025 *
1026 * <P>A new instance of {@linkplain java.net.URLConnection URLConnection} is
1027 * created every time when invoking the
1028 * {@linkplain java.net.URLStreamHandler#openConnection(URL)
1029 * URLStreamHandler.openConnection(URL)} method of the protocol handler for
1030 * this URL.</P>
1031 *
1032 * <P>It should be noted that a URLConnection instance does not establish
1037 * exists a public, specialized URLConnection subclass belonging
1038 * to one of the following packages or one of their subpackages:
1039 * java.lang, java.io, java.util, java.net, the connection
1040 * returned will be of that subclass. For example, for HTTP an
1041 * HttpURLConnection will be returned, and for JAR a
1042 * JarURLConnection will be returned.</P>
1043 *
1044 * @return a {@link java.net.URLConnection URLConnection} linking
1045 * to the URL.
1046 * @exception IOException if an I/O exception occurs.
1047 * @see java.net.URL#URL(java.lang.String, java.lang.String,
1048 * int, java.lang.String)
1049 */
1050 public URLConnection openConnection() throws java.io.IOException {
1051 return handler.openConnection(this);
1052 }
1053
1054 /**
1055 * Same as {@link #openConnection()}, except that the connection will be
1056 * made through the specified proxy; Protocol handlers that do not
1057 * support proxying will ignore the proxy parameter and make a
1058 * normal connection.
1059 *
1060 * Invoking this method preempts the system's default
1061 * {@link java.net.ProxySelector ProxySelector} settings.
1062 *
1063 * @param proxy the Proxy through which this connection
1064 * will be made. If direct connection is desired,
1065 * Proxy.NO_PROXY should be specified.
1066 * @return a {@code URLConnection} to the URL.
1067 * @exception IOException if an I/O exception occurs.
1068 * @exception SecurityException if a security manager is present
1069 * and the caller doesn't have permission to connect
1070 * to the proxy.
1071 * @exception IllegalArgumentException will be thrown if proxy is null,
1072 * or proxy has the wrong type
1073 * @exception UnsupportedOperationException if the subclass that
1074 * implements the protocol handler doesn't support
1075 * this method.
1076 * @see java.net.URL#URL(java.lang.String, java.lang.String,
1077 * int, java.lang.String)
|