⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 urlconnection.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
 calling the <code>getContentType</code> method. If this is  the first time that the application has seen that specific content  type, a content handler for that content type is created:  <ol> <li>If the application has set up a content handler factory instance     using the <code>setContentHandlerFactory</code> method, the     <code>createContentHandler</code> method of that instance is called     with the content type as an argument; the result is a content     handler for that content type. <li>If no content handler factory has yet been set up, or if the     factory's <code>createContentHandler</code> method returns     <code>null</code>, then the application loads the class named:     <blockquote><pre>         sun.net.www.content.&lt;<i>contentType</i>&gt;     </pre></blockquote>     where &lt;<i>contentType</i>&gt; is formed by taking the     content-type string, replacing all slash characters with a     <code>period</code> ('.'), and all other non-alphanumeric characters     with the underscore character '<code>_</code>'. The alphanumeric     characters are specifically the 26 uppercase ASCII letters     '<code>A</code>' through '<code>Z</code>', the 26 lowercase ASCII     letters '<code>a</code>' through '<code>z</code>', and the 10 ASCII     digits '<code>0</code>' through '<code>9</code>'. If the specified     class does not exist, or is not a subclass of     <code>ContentHandler</code>, then an     <code>UnknownServiceException</code> is thrown. </ol><DD><DL><DT><B>Returns:</B><DD>the object fetched. The <code>instanceOf</code> operation               should be used to determine the specific kind of object               returned.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs while               getting the content.<DD><CODE><A HREF="../../java/net/UnknownServiceException.html">UnknownServiceException</A></CODE> - if the protocol does not support               the content type.<DT><B>See Also: </B><DD><A HREF="../../java/net/ContentHandlerFactory.html#createContentHandler(java.lang.String)"><CODE>ContentHandlerFactory.createContentHandler(java.lang.String)</CODE></A>, <A HREF="../../java/net/URLConnection.html#getContentType()"><CODE>getContentType()</CODE></A>, <A HREF="../../java/net/URLConnection.html#setContentHandlerFactory(java.net.ContentHandlerFactory)"><CODE>setContentHandlerFactory(java.net.ContentHandlerFactory)</CODE></A></DL></DD></DL><HR><A NAME="getContent(java.lang.Class[])"><!-- --></A><H3>getContent</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>getContent</B>(<A HREF="../../java/lang/Class.html">Class</A>[]&nbsp;classes)                  throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Retrieves the contents of this URL connection.<DD><DL><DT><B>Parameters:</B><DD><CODE>classes</CODE> - the <code>Class</code> array  indicating the requested types<DT><B>Returns:</B><DD>the object fetched that is the first match of the type               specified in the classes array. null if none of                the requested types are supported.               The <code>instanceOf</code> operation should be used to                determine the specific kind of object returned.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs while               getting the content.<DD><CODE><A HREF="../../java/net/UnknownServiceException.html">UnknownServiceException</A></CODE> - if the protocol does not support               the content type.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#getContent()"><CODE>getContent()</CODE></A>, <A HREF="../../java/net/ContentHandlerFactory.html#createContentHandler(java.lang.String)"><CODE>ContentHandlerFactory.createContentHandler(java.lang.String)</CODE></A>, <A HREF="../../java/net/URLConnection.html#getContent(java.lang.Class[])"><CODE>getContent(java.lang.Class[])</CODE></A>, <A HREF="../../java/net/URLConnection.html#setContentHandlerFactory(java.net.ContentHandlerFactory)"><CODE>setContentHandlerFactory(java.net.ContentHandlerFactory)</CODE></A></DL></DD></DL><HR><A NAME="getPermission()"><!-- --></A><H3>getPermission</H3><PRE>public <A HREF="../../java/security/Permission.html">Permission</A> <B>getPermission</B>()                         throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns <code>java.security.AllPermission</code>. Subclasses should override this method and return the permission that best represents the permission required to make a  a connection to the URL. For example, a <code>URLConnection</code> representing a <code>file:</code> URL would return a  <code>java.io.FilePermission</code> object. <p>The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.  <p>Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained <em>after</em> the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested <em>before</em> connecting.<DD><DL><DT><B>Returns:</B><DD>the permission object representing the permission necessary to make the connection represented by this URLConnection.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if the computation of the permission requires network or file I/O and an exception occurs while computing it.</DL></DD></DL><HR><A NAME="getInputStream()"><!-- --></A><H3>getInputStream</H3><PRE>public <A HREF="../../java/io/InputStream.html">InputStream</A> <B>getInputStream</B>()                           throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns an input stream that reads from this open connection.<DD><DL><DT><B>Returns:</B><DD>an input stream that reads from this open connection.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs while               creating the input stream.<DD><CODE><A HREF="../../java/net/UnknownServiceException.html">UnknownServiceException</A></CODE> - if the protocol does not support               input.</DL></DD></DL><HR><A NAME="getOutputStream()"><!-- --></A><H3>getOutputStream</H3><PRE>public <A HREF="../../java/io/OutputStream.html">OutputStream</A> <B>getOutputStream</B>()                             throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns an output stream that writes to this connection.<DD><DL><DT><B>Returns:</B><DD>an output stream that writes to this connection.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs while               creating the output stream.<DD><CODE><A HREF="../../java/net/UnknownServiceException.html">UnknownServiceException</A></CODE> - if the protocol does not support               output.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a <code>String</code> representation of this URL connection.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this <code>URLConnection</code>.</DL></DD></DL><HR><A NAME="setDoInput(boolean)"><!-- --></A><H3>setDoInput</H3><PRE>public void <B>setDoInput</B>(boolean&nbsp;doinput)</PRE><DL><DD>Sets the value of the <code>doInput</code> field for this  <code>URLConnection</code> to the specified value.  <p> A URL connection can be used for input and/or output.  Set the DoInput flag to true if you intend to use the URL connection for input, false if not.  The default is true unless DoOutput is explicitly set to true, in which case DoInput defaults to false.<DD><DL><DT><B>Parameters:</B><DD><CODE>doinput</CODE> - the new value.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#doInput"><CODE>doInput</CODE></A>, <A HREF="../../java/net/URLConnection.html#getDoInput()"><CODE>getDoInput()</CODE></A></DL></DD></DL><HR><A NAME="getDoInput()"><!-- --></A><H3>getDoInput</H3><PRE>public boolean <B>getDoInput</B>()</PRE><DL><DD>Returns the value of this <code>URLConnection</code>'s <code>doInput</code> flag.<DD><DL><DT><B>Returns:</B><DD>the value of this <code>URLConnection</code>'s          <code>doInput</code> flag.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#setDoInput(boolean)"><CODE>setDoInput(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setDoOutput(boolean)"><!-- --></A><H3>setDoOutput</H3><PRE>public void <B>setDoOutput</B>(boolean&nbsp;dooutput)</PRE><DL><DD>Sets the value of the <code>doOutput</code> field for this  <code>URLConnection</code> to the specified value.  <p> A URL connection can be used for input and/or output.  Set the DoOutput flag to true if you intend to use the URL connection for output, false if not.  The default is false.<DD><DL><DT><B>Parameters:</B><DD><CODE>dooutput</CODE> - the new value.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#getDoOutput()"><CODE>getDoOutput()</CODE></A></DL></DD></DL><HR><A NAME="getDoOutput()"><!-- --></A><H3>getDoOutput</H3><PRE>public boolean <B>getDoOutput</B>()</PRE><DL><DD>Returns the value of this <code>URLConnection</code>'s <code>doOutput</code> flag.<DD><DL><DT><B>Returns:</B><DD>the value of this <code>URLConnection</code>'s          <code>doOutput</code> flag.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#setDoOutput(boolean)"><CODE>setDoOutput(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setAllowUserInteraction(boolean)"><!-- --></A><H3>setAllowUserInteraction</H3><PRE>public void <B>setAllowUserInteraction</B>(boolean&nbsp;allowuserinteraction)</PRE><DL><DD>Set the value of the <code>allowUserInteraction</code> field of  this <code>URLConnection</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>allowuserinteraction</CODE> - the new value.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#getAllowUserInteraction()"><CODE>getAllowUserInteraction()</CODE></A></DL></DD></DL><HR><A NAME="getAllowUserInteraction()"><!-- --></A><H3>getAllowUserInteraction</H3><PRE>public boolean <B>getAllowUserInteraction</B>()</PRE><DL><DD>Returns the value of the <code>allowUserInteraction</code> field for this object.<DD><DL><DT><B>Returns:</B><DD>the value of the <code>allowUserInteraction</code> field for          this object.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#setAllowUserInteraction(boolean)"><CODE>setAllowUserInteraction(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setDefaultAllowUserInteraction(boolean)"><!-- --></A><H3>setDefaultAllowUserInteraction</H3><PRE>public static void <B>setDefaultAllowUserInteraction</B>(boolean&nbsp;defaultallowuserinteraction)</PRE><DL><DD>Sets the default value of the  <code>allowUserInteraction</code> field for all future  <code>URLConnection</code> objects to the specified value.<DD><DL><DT><B>Parameters:</B><DD><CODE>defaultallowuserinteraction</CODE> - the new value.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#getDefaultAllowUserInteraction()"><CODE>getDefaultAllowUserInteraction()</CODE></A></DL></DD></DL><HR><A NAME="getDefaultAllowUserInteraction()"><!-- --></A><H3>getDefaultAllowUserInteraction</H3><PRE>public static boolean <B>getDefaultAllowUserInteraction</B>()</PRE><DL><DD>Returns the default value of the <code>allowUserInteraction</code> field. <p> Ths default is "sticky", being a part of the static state of all URLConnections.  This flag applies to the next, and all following URLConnections that are created.<DD><DL><DT><B>Returns:</B><DD>the default value of the <code>allowUserInteraction</code>          field.<DT><B>See Also: </B><DD><A HREF="../../java/net/URLConnection.html#setDefaultAllowUserInteraction(boolean)"><CODE>setDefaultAllowUserInteraction(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setUseCaches(boolean)"><!-- --></A><H3>setUseCaches</H3><PRE>public void <B>setUseCaches</B>(boolean&nbsp;usecaches)</PRE><DL><DD>Sets the value of the <code>useCaches</code> field of this  <code>URLConnection</code> to the specified value.  <p> Some protocols do caching of documents.  Occasionally, it is important to be able to "tunnel through" and ignore the caches (e.g., the "reload" button in a browser).  If the UseCaches flag

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -