client.java

来自「简单cs编程,由于客户端请求服务器计算,无gui组件」· Java 代码 · 共 24 行

JAVA
24
字号
import java.net.*; 
import java.io.*; 

public class Client{ 
static Socket sammy; 
public static void main(String[] args)throws Exception{ 
sammy=new Socket(InetAddress.getLocalHost(),20000); 
BufferedReader in=new BufferedReader(new InputStreamReader(sammy.getInputStream())); 
PrintWriter out=new PrintWriter(sammy.getOutputStream()); 
BufferedReader wt=new BufferedReader(new InputStreamReader(System.in)); 
System.out.println("input some code('end' to over)");
while(true){ 
String str=wt.readLine();
out.println(str); 
out.flush(); 
if(str.equals("end")){ 
break;} 
System.out.println(in.readLine()); 
} 
System.out.println(in.readLine());
sammy.close(); 
} 
} 

⌨️ 快捷键说明

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