📄 client.java.bak
字号:
import java.io.*;
import java.net.*;
public class Client
{
public static String readLine()
throws IOException {
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
return br.readLine();
}
public static void main(String[] args)
{String s=null;
Socket mysocket=null;
DataInputStream in=null;
DataOutputStream out=null;
try{mysocket=new Socket("localhost",4331);
in=new DataInputStream(mysocket.getInputStream());
out=new DataOutputStream(mysocket.getOutputStream());
System.out.println("Enter strings when prompted.");
System.out.print("Enter your first number: ");
String s1 = readLine();
System.out.print("Enter your Operator : ");
String s2 = readLine();
System.out.print("Enter your second number: ");
String s3 = readLine();
out.writeUTF(s1); out.writeUTF(s2); out.writeUTF(s3);
while(true)
{s=in.readUTF();
if(s!=null) break;}
System.out.println("The total:" + s1 + "+" + s3 + "=" + s);
mysocket.close();}
catch(IOException e){System.out.println("无法连接,请确认输入是否正确");}
//System.out.println(s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -