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

📄 echo.java

📁 一步 教你学会java 完成一个完整的SWT系统 是本人学习java时按教程一步一步写下来的咯
💻 JAVA
字号:
/** *  Example code for JavaOne hands-on J2SE lab * *  Concurrency utilities (JSR-166) example **/package threadpool;import java.net.*;import java.io.*;import java.util.concurrent.*;/** *  Echo characters from the keyboard to a socket.  Simplified version of *  telnet **/public class Echo {  /**   *  Main entry point   *   * @param args Command line arguments   **/  public static void main(String[] args) {    String host = null;    int port = 0;    if (args.length < 2) {      host = "127.0.0.1";      port = 8100;    }    OutputStream os = null;    try {      Socket s = new Socket(host, port);      os = s.getOutputStream();      System.out.println("Connection established to server. Type characters and press <ENTER> to send");      System.out.println("Type EXIT and press <RETURN> to exit");      /*  Read from the standard input and send to the remote socket  */      while (true) {        byte[] inData = new byte[100];        System.in.read(inData);        String inString = new String(inData);        if (inString.substring(0, 4).compareTo("EXIT") == 0)          System.exit(1);        os.write(inData);      }    } catch (Exception e) {      System.out.println("Failed to connect to remote host: " +        e.getMessage());    }  }}

⌨️ 快捷键说明

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