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

📄 protocol.java

📁 已经移植好的java虚拟机
💻 JAVA
字号:
/* *  Copyright (c) 1999 Sun Microsystems, Inc., 901 San Antonio Road, *  Palo Alto, CA 94303, U.S.A.  All Rights Reserved. * *  Sun Microsystems, Inc. has intellectual property rights relating *  to the technology embodied in this software.  In particular, and *  without limitation, these intellectual property rights may include *  one or more U.S. patents, foreign patents, or pending *  applications.  Sun, Sun Microsystems, the Sun logo, Java, KJava, *  and all Sun-based and Java-based marks are trademarks or *  registered trademarks of Sun Microsystems, Inc.  in the United *  States and other countries. * *  This software is distributed under licenses restricting its use, *  copying, distribution, and decompilation.  No part of this *  software may be reproduced in any form by any means without prior *  written authorization of Sun and its licensors, if any. * *  FEDERAL ACQUISITIONS:  Commercial Software -- Government Users *  Subject to Standard License Terms and Conditions *//* * WARNING - THIS IS AN EXPERIMENTAL FEATURE OF KVM THAT MAY, OR MAY NOT * EXIST IN A FUTURE VERSION OF THIS PRODUCT. IT IS NOT A PART OF THE * CLDC SPECIFICATION AND IS PROVIDED FOR ILLUSTRATIVE PURPOSES ONLY */package com.sun.cldc.io.j2se.http;import java.io.*;import java.net.*;import javax.microedition.io.*;import com.sun.cldc.io.j2se.*;/** * HTTP connection for J2SE. * * @author  Nik Shaylor * @version 1.0 01/03/2000 */public class Protocol extends com.sun.cldc.io.ConnectionBase implements ContentConnection {    /** URL Connection object */    URLConnection conn = null;    /**     * Open the http connection     * @param name the target for the connection     * @param mode The access mode     * @param timeouts A flag to indicate that the called wants timeout exceptions     * <p>     * The name string for this protocol should be:     * "<name or IP number>:<port number>     */    public void open(String name, int mode, boolean timeouts) throws IOException {        if(name.charAt(0) != '/' || name.charAt(1) != '/') {            throw new IllegalArgumentException("Protocol must start with \"//\" "+name);        }        name = name.substring(2);        URL url = new URL(name);        conn = url.openConnection();        conn.connect();    }    /**     * Returns an input stream for this socket.     *     * @return     an input stream for reading bytes from this socket.     * @exception  IOException  if an I/O error occurs when creating the     *                          input stream.     */    public InputStream openInputStream() throws IOException {        return new UniversalFilterInputStream(this, conn.getInputStream());    }    /**     * Returns an output stream for this socket.     *     * @return     an output stream for writing bytes to this socket.     * @exception  IOException  if an I/O error occurs when creating the     *                          output stream.     */    public OutputStream openOutputStream() throws IOException {        return new UniversalFilterOutputStream(this, conn.getOutputStream());    }    /**     * Returns the value of the <code>content-type</code> header field.     *     * @return  the content type of the resource that the URL references,     *          or <code>null</code> if not known.     */    public String getType() {        return conn.getContentType();    }    /**     * 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.     */    public String getEncoding() {        return conn.getContentEncoding();    }    /*     * Returns the contents of the specified header field.     *     * @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 conn.getHeaderField(name);    }    /**     * Returns the value of the <code>content-length</code> header field.     *     * @return  the content length of the resource that this connection's URL     *          references, or <code>-1</code> if the content length is     *          not known.     */    public long getLength() {        return conn.getContentLength();    }    /**     * Close the connection.     *     * @exception  IOException  if an I/O error occurs when closing the     *                          connection.     */    public void close() throws IOException {    }}

⌨️ 快捷键说明

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