📄 testsockclient.java
字号:
import java.net.*;
import java.io.*;
public class TestSockClient {
public static void main(String[] args) {
InputStream is = null; OutputStream os = null;
try {
Socket socket = new Socket("localhost",5888);
is = socket.getInputStream();
os = socket.getOutputStream();
DataInputStream dis = new DataInputStream(is);
DataOutputStream dos = new DataOutputStream(os);
dos.writeUTF("hey");
String s = null;
if((s=dis.readUTF())!=null);
System.out.println(s);
dos.close();
dis.close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {e.printStackTrace();}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -