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

📄 ppppoi.java

📁 当我们编写JAVA应用程序时
💻 JAVA
字号:
import java.io.*;
import java.net.*;
public class EchoTest{
  public static void main(Stringargs){
  Socket echoSocket=null;
  DataOutputStream os-null;
  DataInputsStream is=null;
  DataInputStream stdIn=new DataInputStream(System.in);
  try{ echoSocket=new Socket(″myHost″,4444);
   os=new DataOutputStream(echoSocket.getOutputStream());
   is=newDataInputStream(echoSocket.getInputStream());
  } catch(UnknownHostException e){
  System.err.println(″Don`t know about host:myHost″);
  } catch(IOException e){
  System.err.println(″Couldn`t get I/O for the connection to:myHost″);
  }
  if(echoSocket!=null && os!=null&& is!=null){
  try{
   String userInput;
    while((userInput=stdin.readLine())!
=null){
   os.writeBytes(userInput);
   os.writeByte(″′);
   System.out.println(″echo:″+is.readLine()); }
   os.close();
   is.close();
   echoSocket.close();
   } catch (IOException e){
    System.err.println(″I/O failed on the connection to:myHost″);
   }
  }
}
}

⌨️ 快捷键说明

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