simpleclient.java

来自「网络+多线程+输入输出流的结合运用」· Java 代码 · 共 28 行

JAVA
28
字号
package socket;
import java.net.*;
   import java.io.*;

   public class SimpleClient {
   public static void main(String args[]) throws IOException {

   Socket s1;
   InputStream s1In;
   DataInputStream dis;

   // Open your connection to sunbert, at port 5432
   s1 = new Socket("localhost",5432);

   // Get an input file handle from the socket and read the input
   s1In = s1.getInputStream();
   dis = new DataInputStream(s1In);

   String st = new String (dis.readUTF());
   System.out.println(st);

   // When done, just close the connection and exit
   s1In.close();
   s1.close();
   } //end of method main()
   } //end of class SimpleClient()

⌨️ 快捷键说明

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