📄 url.html
字号:
<BR> Returns the host name of this <code>URL</code>, if applicable.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getPath()">getPath</A></B>()</CODE><BR> Returns the path part of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getPort()">getPort</A></B>()</CODE><BR> Returns the port number of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getProtocol()">getProtocol</A></B>()</CODE><BR> Returns the protocol name of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getQuery()">getQuery</A></B>()</CODE><BR> Returns the query part of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getRef()">getRef</A></B>()</CODE><BR> Returns the anchor (also known as the "reference") of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#getUserInfo()">getUserInfo</A></B>()</CODE><BR> Returns the userInfo part of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#hashCode()">hashCode</A></B>()</CODE><BR> Creates an integer suitable for hash table indexing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/net/URLConnection.html">URLConnection</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#openConnection()">openConnection</A></B>()</CODE><BR> Returns a <code>URLConnection</code> object that represents a connection to the remote object referred to by the <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/io/InputStream.html">InputStream</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#openStream()">openStream</A></B>()</CODE><BR> Opens a connection to this <code>URL</code> and returns an <code>InputStream</code> for reading from that connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#sameFile(java.net.URL)">sameFile</A></B>(<A HREF="../../java/net/URL.html">URL</A> other)</CODE><BR> Compares two URLs, excluding the "ref" fields.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)">set</A></B>(<A HREF="../../java/lang/String.html">String</A> protocol, <A HREF="../../java/lang/String.html">String</A> host, int port, <A HREF="../../java/lang/String.html">String</A> file, <A HREF="../../java/lang/String.html">String</A> ref)</CODE><BR> Sets the fields of the URL.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)">set</A></B>(<A HREF="../../java/lang/String.html">String</A> protocol, <A HREF="../../java/lang/String.html">String</A> host, int port, <A HREF="../../java/lang/String.html">String</A> authority, <A HREF="../../java/lang/String.html">String</A> userInfo, <A HREF="../../java/lang/String.html">String</A> path, <A HREF="../../java/lang/String.html">String</A> query, <A HREF="../../java/lang/String.html">String</A> ref)</CODE><BR> Sets the specified 8 fields of the URL.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)">setURLStreamHandlerFactory</A></B>(<A HREF="../../java/net/URLStreamHandlerFactory.html">URLStreamHandlerFactory</A> fac)</CODE><BR> Sets an application's <code>URLStreamHandlerFactory</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#toExternalForm()">toExternalForm</A></B>()</CODE><BR> Constructs a string representation of this <code>URL</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/net/URL.html#toString()">toString</A></B>()</CODE><BR> Constructs a string representation of this <code>URL</code>.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="URL(java.lang.String, java.lang.String, int, java.lang.String)"><!-- --></A><H3>URL</H3><PRE>public <B>URL</B>(<A HREF="../../java/lang/String.html">String</A> protocol, <A HREF="../../java/lang/String.html">String</A> host, int port, <A HREF="../../java/lang/String.html">String</A> file) throws <A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></PRE><DL><DD>Creates a <code>URL</code> object from the specified <code>protocol</code>, <code>host</code>, <code>port</code> number, and <code>file</code>. Specifying a <code>port</code> number of <code>-1</code> indicates that the URL should use the default port for the protocol. <p> If this is the first URL object being created with the specified protocol, a <i>stream protocol handler</i> object, an instance of class <code>URLStreamHandler</code>, is created for that protocol: <ol> <li>If the application has previously set up an instance of <code>URLStreamHandlerFactory</code> as the stream handler factory, then the <code>createURLStreamHandler</code> method of that instance is called with the protocol string as an argument to create the stream protocol handler. <li>If no <code>URLStreamHandlerFactory</code> has yet been set up, or if the factory's <code>createURLStreamHandler</code> method returns <code>null</code>, then the constructor finds the value of the system property: <blockquote><pre> java.protocol.handler.pkgs </pre></blockquote> If the value of that system property is not <code>null</code>, it is interpreted as a list of packages separated by a vertical slash character '<code>|</code>'. The constructor tries to load the class named: <blockquote><pre> <<i>package</i>>.<<i>protocol</i>>.Handler </pre></blockquote> where <<i>package</i>> is replaced by the name of the package and <<i>protocol</i>> is replaced by the name of the protocol. If this class does not exist, or if the class exists but it is not a subclass of <code>URLStreamHandler</code>, then the next package in the list is tried. <li>If the previous step fails to find a protocol handler, then the constructor tries to load the class named: <blockquote><pre> sun.net.www.protocol.<<i>protocol</i>>.Handler </pre></blockquote> If this class does not exist, or if the class exists but it is not a subclass of <code>URLStreamHandler</code>, then a <code>MalformedURLException</code> is thrown. </ol><DD><DL><DT><B>Parameters:</B><DD><CODE>protocol</CODE> - the name of the protocol to use.<DD><CODE>host</CODE> - the name of the host.<DD><CODE>port</CODE> - the port number on the host.<DD><CODE>file</CODE> - the file on the host<DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></CODE> - if an unknown protocol is specified.<DT><B>See Also: </B><DD><A HREF="../../java/lang/System.html#getProperty(java.lang.String)"><CODE>System.getProperty(java.lang.String)</CODE></A>, <A HREF="../../java/net/URL.html#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)"><CODE>setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)</CODE></A>, <A HREF="../../java/net/URLStreamHandler.html"><CODE>URLStreamHandler</CODE></A>, <A HREF="../../java/net/URLStreamHandlerFactory.html#createURLStreamHandler(java.lang.String)"><CODE>URLStreamHandlerFactory.createURLStreamHandler(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="URL(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>URL</H3><PRE>public <B>URL</B>(<A HREF="../../java/lang/String.html">String</A> protocol, <A HREF="../../java/lang/String.html">String</A> host, <A HREF="../../java/lang/String.html">String</A> file) throws <A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></PRE><DL><DD>Creates a URL from the specified <code>protocol</code> name, <code>host</code> name, and <code>file</code> name. The default port for the specified protocol is used. <p> This method is equivalent to calling the four-argument constructor with the arguments being <code>protocol</code>, <code>host</code>, <code>-1</code>, and <code>file</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>protocol</CODE> - the name of the protocol to use.<DD><CODE>host</CODE> - the name of the host.<DD><CODE>file</CODE> - the file on the host.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></CODE> - if an unknown protocol is specified.<DT><B>See Also: </B><DD><A HREF="../../java/net/URL.html#URL(java.lang.String, java.lang.String, int, java.lang.String)"><CODE>URL(java.lang.String, java.lang.String, int, java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="URL(java.lang.String, java.lang.String, int, java.lang.String, java.net.URLStreamHandler)"><!-- --></A><H3>URL</H3><PRE>public <B>URL</B>(<A HREF="../../java/lang/String.html">String</A> protocol, <A HREF="../../java/lang/String.html">String</A> host, int port, <A HREF="../../java/lang/String.html">String</A> file, <A HREF="../../java/net/URLStreamHandler.html">URLStreamHandler</A> handler) throws <A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></PRE><DL><DD>Creates a <code>URL</code> object from the specified <code>protocol</code>, <code>host</code>, <code>port</code> number, <code>file</code>, and <code>handler</code>. Specifying a <code>port</code> number of <code>-1</code> indicates that the URL should use the default port for the protocol. Specifying a <code>handler</code> of <code>null</code> indicates that the URL should use a default stream handler for the protocol, as outlined for: java.net.URL#URL(java.lang.String, java.lang.String, int, java.lang.String) <p>If the handler is not null and there is a security manager, the security manager's <code>checkPermission</code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -