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

📄 urlconnection.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	return getHeaderField("content-type");    }    /**     * Returns the value of the <code>content-encoding</code> header field.     *     * @return  the content encoding of the resource that the URL references,     *          or <code>null</code> if not known.     * @see     java.net.URLConnection#getHeaderField(java.lang.String)     */    public String getContentEncoding() {	return getHeaderField("content-encoding");    }    /**     * Returns the value of the <code>expires</code> header field.      *     * @return  the expiration date of the resource that this URL references,     *          or 0 if not known. The value is the number of milliseconds since     *          January 1, 1970 GMT.     * @see     java.net.URLConnection#getHeaderField(java.lang.String)     */    public long getExpiration() {	return getHeaderFieldDate("expires", 0);    }    /**     * Returns the value of the <code>date</code> header field.      *     * @return  the sending date of the resource that the URL references,     *          or <code>0</code> if not known. The value returned is the     *          number of milliseconds since January 1, 1970 GMT.     * @see     java.net.URLConnection#getHeaderField(java.lang.String)     */    public long getDate() {	return getHeaderFieldDate("date", 0);    }    /**     * Returns the value of the <code>last-modified</code> header field.      * The result is the number of milliseconds since January 1, 1970 GMT.     *     * @return  the date the resource referenced by this     *          <code>URLConnection</code> was last modified, or 0 if not known.     * @see     java.net.URLConnection#getHeaderField(java.lang.String)     */    public long getLastModified() {	return getHeaderFieldDate("last-modified", 0);    }    /**     * Returns the value of the named header field.     * <p>     * If called on a connection that sets the same header multiple times     * with possibly different values, only the last value is returned.     *      *     * @param   name   the name of a header field.     * @return  the value of the named header field, or <code>null</code>     *          if there is no such field in the header.     */    public String getHeaderField(String name) {	return null;    }    /**     * Returns an unmodifiable Map of the header fields.     * The Map keys are Strings that represent the     * response-header field names. Each Map value is an     * unmodifiable List of Strings that represents      * the corresponding field values.     *     * @return a Map of header fields     * @since 1.4     */    public Map getHeaderFields() {        return Collections.EMPTY_MAP;    }    /**     * Returns the value of the named field parsed as a number.     * <p>     * This form of <code>getHeaderField</code> exists because some      * connection types (e.g., <code>http-ng</code>) have pre-parsed      * headers. Classes for that connection type can override this method      * and short-circuit the parsing.      *     * @param   name      the name of the header field.     * @param   Default   the default value.     * @return  the value of the named field, parsed as an integer. The     *          <code>Default</code> value is returned if the field is     *          missing or malformed.     */    public int getHeaderFieldInt(String name, int Default) {	String value = getHeaderField(name);	try {	    return Integer.parseInt(value);	} catch (Exception e) { }	return Default;    }    /**     * Returns the value of the named field parsed as date.     * The result is the number of milliseconds since January 1, 1970 GMT     * represented by the named field.      * <p>     * This form of <code>getHeaderField</code> exists because some      * connection types (e.g., <code>http-ng</code>) have pre-parsed      * headers. Classes for that connection type can override this method      * and short-circuit the parsing.      *     * @param   name     the name of the header field.     * @param   Default   a default value.     * @return  the value of the field, parsed as a date. The value of the     *          <code>Default</code> argument is returned if the field is     *          missing or malformed.     */    public long getHeaderFieldDate(String name, long Default) {	try {            DateFormat df = DateFormat.getDateInstance();	    	    return df.parse(getHeaderField(name)).getTime();	} catch(Throwable t) {}	return Default;    }    /**     * Returns the key for the <code>n</code><sup>th</sup> header field.     * It returns <code>null</code> if there are fewer than <code>n+1</code> fields.      *     * @param   n   an index, where n>=0     * @return  the key for the <code>n</code><sup>th</sup> header field,     *          or <code>null</code> if there are fewer than <code>n+1</code>     *		fields.     */    public String getHeaderFieldKey(int n) {	return null;    }    /**     * Returns the value for the <code>n</code><sup>th</sup> header field.      * It returns <code>null</code> if there are fewer than     * <code>n+1</code>fields.      * <p>     * This method can be used in conjunction with the      * {@link #getHeaderFieldKey(int) getHeaderFieldKey} method to iterate through all      * the headers in the message.      *     * @param   n   an index, where n>=0     * @return  the value of the <code>n</code><sup>th</sup> header field     *		or <code>null</code> if there are fewer than <code>n+1</code> fields     * @see     java.net.URLConnection#getHeaderFieldKey(int)     */    public String getHeaderField(int n) {	return null;    }    /**     * Retrieves the contents of this URL connection.      * <p>     * This method first determines the content type of the object by      * 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>     *     * @return     the object fetched. The <code>instanceof</code> operator     *               should be used to determine the specific kind of object     *               returned.     * @exception  IOException              if an I/O error occurs while     *               getting the content.     * @exception  UnknownServiceException  if the protocol does not support     *               the content type.     * @see        java.net.ContentHandlerFactory#createContentHandler(java.lang.String)     * @see        java.net.URLConnection#getContentType()     * @see        java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)     */    public Object getContent() throws IOException {        // Must call getInputStream before GetHeaderField gets called        // so that FileNotFoundException has a chance to be thrown up        // from here without being caught.        getInputStream();	return getContentHandler().getContent(this);    }    /**     * Retrieves the contents of this URL connection.      *     * @param classes the <code>Class</code> array      * indicating the requested types     * @return     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> operator should be used to      *               determine the specific kind of object returned.     * @exception  IOException              if an I/O error occurs while     *               getting the content.     * @exception  UnknownServiceException  if the protocol does not support     *               the content type.     * @see        java.net.URLConnection#getContent()     * @see        java.net.ContentHandlerFactory#createContentHandler(java.lang.String)     * @see        java.net.URLConnection#getContent(java.lang.Class[])     * @see        java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)     */    public Object getContent(Class[] classes) throws IOException {        // Must call getInputStream before GetHeaderField gets called        // so that FileNotFoundException has a chance to be thrown up        // from here without being caught.        getInputStream();	return getContentHandler().getContent(this, classes);    }    /**       * 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.     *     * @return the permission object representing the permission     * necessary to make the connection represented by this     * URLConnection.      *     * @exception IOException if the computation of the permission     * requires network or file I/O and an exception occurs while     * computing it.       */    public Permission getPermission() throws IOException {	return SecurityConstants.ALL_PERMISSION;    }    /**     * Returns an input stream that reads from this open connection.     *     * @return     an input stream that reads from this open connection.     * @exception  IOException              if an I/O error occurs while     *               creating the input stream.     * @exception  UnknownServiceException  if the protocol does not support     *               input.     */    public InputStream getInputStream() throws IOException {	throw new UnknownServiceException("protocol doesn't support input");    }    /**     * Returns an output stream that writes to this connection.     *     * @return     an output stream that writes to this connection.     * @exception  IOException              if an I/O error occurs while     *               creating the output stream.     * @exception  UnknownServiceException  if the protocol does not support     *               output.     */    public OutputStream getOutputStream() throws IOException {	throw new UnknownServiceException("protocol doesn't support output");    }    /**     * Returns a <code>String</code> representation of this URL connection.     *     * @return  a string representation of this <code>URLConnection</code>.     */    public String toString() {	return this.getClass().getName() + ":" + url;    }    /**     * 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.     *     * @param   doinput   the new value.     * @throws IllegalStateException if already connected     * @see     java.net.URLConnection#doInput     * @see #getDoInput()     */    public void setDoInput(boolean doinput) {	if (connected)	    throw new IllegalStateException("Already connected");	doInput = doinput;    }    /**     * Returns the value of this <code>URLConnection</code>'s     * <code>doInput</code> flag.     *     * @return  the value of this <code>URLConnection</code>'s     *          <code>doInput</code> flag.     * @see     #setDoInput(boolean)     */    public boolean getDoInput() {	return doInput;    }    /**     * 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.     *     * @param   dooutput   the new value.     * @throws IllegalStateException if already connected     * @see #getDoOutput()     */    public void setDoOutput(boolean dooutput) {	if (connected)	    throw new IllegalStateException("Already connected");	doOutput = dooutput;    }    /**     * Returns the value of this <code>URLConnection</code>'s     * <code>doOutput</code> flag.     *     * @return  the value of this <code>URLConnection</code>'s     *          <code>doOutput</code> flag.     * @see     #setDoOutput(boolean)     */    public boolean getDoOutput() {	return doOutput;    }    /**     * Set the value of the <code>allowUserInteraction</code> field of      * this <code>URLConnection</code>.      *     * @param   allowuserinteraction   the new value.     * @throws IllegalStateException if already connected     * @see     #getAllowUserInteraction()     */    public void setAllowUserInteraction(boolean allowuserinteraction) {	if (connected)	    throw new IllegalStateException("Already connected");	allowUserInteraction = allowuserinteraction;    }    /**     * Returns the value of the <code>allowUserInteraction</code> field for     * this object.     *     * @return  the value of the <code>allowUserInteraction</code> field for     *          this object.     * @see     #setAllowUserInteraction(boolean)     */    public boolean getAllowUserInteraction() {	return allowUserInteraction;    }    /**

⌨️ 快捷键说明

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