⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chatclient.java

📁 java应用开发详解
💻 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 + -