📄 chatclient.java
字号:
import java.net.*;import java.io.*;public class ChatClient { Socket socket; DataInputStream input; DataInputStream user; PrintStream output; public ChatClient() { try { socket = new Socket("localhost",8123); input = new DataInputStream( socket.getInputStream() ); output = new PrintStream( socket.getOutputStream() ); } catch(IOException e) { System.out.println("Abnormal chat client socket condition: "+ e ); } user = new DataInputStream( System.in ); String s = new String(); System.out.println("This is Chat Client."); System.out.println("Enter your text: (Hit [Enter] twice to exit)"); do { try { s = user.readLine(); output.println(s); output.flush(); } catch(IOException e) {} System.out.println("User entered: " + s); } while ( !s.equals("") ); output.close(); } public static void main(String[] args) { new ChatClient(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -