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

📄 fingerurlconnection.java

📁 java网络编程 java netwok program 著名的坚果系列的书的代码
💻 JAVA
字号:
package com.macfaq.net.www.protocol.finger;import java.net.*;import java.io.*;public class FingerURLConnection extends URLConnection {  private Socket connection = null;    public final static int DEFAULT_PORT = 79;  public FingerURLConnection(URL u) {    super(u);  }  public synchronized InputStream getInputStream() throws IOException {      if (!connected) this.connect();    InputStream in = this.connection.getInputStream();    return in;      }  public String getContentType() {    return "text/plain";  }  public synchronized void connect() throws IOException {      if (!connected) {      int port = url.getPort();      if ( port < 1 || port > 65535) {        port = DEFAULT_PORT;      }      this.connection = new Socket(url.getHost(), port);      OutputStream out = this.connection.getOutputStream();      String names = url.getFile();      if (names != null && !names.equals("")) {        // delete initial /        names = names.substring(1);        names = URLDecoder.decode(names);        byte[] result;        try {          result = names.getBytes("ASCII");        }        catch (UnsupportedEncodingException ex) {          result = names.getBytes();          }        out.write(result);      }      out.write('\r');      out.write('\n');      out.flush();      this.connected = true;    }   }}

⌨️ 快捷键说明

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