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

📄 streamconnectionelement.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
字号:
/*  * @(#)StreamConnectionElement.java	1.6 01/06/11 * Copyright (c) 2001 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information").  You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. * * StreamConnectionElement.java * * Created on March 1, 2001, 4:34 PM * */package com.sun.midp.io.j2me.http;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.io.DataInputStream;import java.io.DataOutputStream;import java.util.Hashtable;import java.util.Enumeration;import javax.microedition.io.StreamConnection;import javax.microedition.io.Connector;/** * This class implements the necessary functionality * for an HTTP connection pool element container. Each * element contains appropriate http connection information * including a reference to the underlying socket stream connection. *  * @version 1.0 */class StreamConnectionElement      implements StreamConnection {        /** current url */    protected String                    m_url;    /** current host name */    protected String                    m_host;    /** connection name */    protected String                    m_connection;    /** http port number */    protected int                       m_port;    /** connection stream to http server */    protected StreamConnection          m_stream;    /** input stream to http server */    private DataInputStream             m_data_input_stream;    /** output stream to http server */    private DataOutputStream            m_data_output_stream;    /** in use flag */    protected boolean                   m_in_use;    /** start time in milliseconds */    protected long                      m_time;        /**     * create a new instance of this class.     *     * @param p_url                 The URL for the connection     * @param p_host                The Hostname for the connection     * @param p_port                The port number for the connection     * @param p_connection          The name for the connection     * @param p_sc                  The stream connection     * @param p_dos                 The data output stream     * @param p_dis                 The data input stream     */    public StreamConnectionElement(String p_url,                                     String p_host,                                     int p_port,                                     String p_connection,                                     StreamConnection p_sc,                                     DataOutputStream p_dos,                                     DataInputStream p_dis) {                m_port = p_port;        m_url = p_url;        m_host = p_host;        m_stream = (StreamConnection)p_sc;        m_connection = p_connection;        m_data_output_stream = p_dos;        m_data_input_stream = p_dis;        m_time = System.currentTimeMillis();            }           /**     * set the current in use flag     *      * @param p_in_use              set the current in use flag     */    public void setInUse(boolean p_in_use) { m_in_use = p_in_use; }    /**     * get the current output stream for the stream connection     *     * @return                     output stream     */    public OutputStream openOutputStream() {        return m_data_output_stream;    }    /**     * get the current data output stream for the stream connection     *     * @return                     data output stream     */    public DataOutputStream openDataOutputStream() {         return m_data_output_stream;    }    /**     * get the current data stream for the stream connection     *     * @return                     input stream     */    public InputStream openInputStream() {         return m_data_input_stream;    }    /**     * get the current data input stream for the stream connection     *     * @return                     data input stream     */    public DataInputStream openDataInputStream() {         return m_data_input_stream;    }    /**     * Close the stream connection.     * @exception IOException thrown if there was an error closing the stream     */    public void close() throws IOException {        m_stream.close();    }}                        

⌨️ 快捷键说明

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