java发送字符流怎么写

来源:百度知道 编辑:UC知道 时间:2024/05/10 14:04:37
java发送字符流怎么写
是字符流,不是字节流
我是说发送字符流
outStream = new DataOutputStream(s.getOutputStream());
outStream.writeUTF("夏雨");
outStream.flush();
类似这个(这是发送字节流)

import java.io.*;
public class Echo {
public static void main(String[] args) {
BufferedReader in =
new BufferedReader(
new InputStreamReader(System.in));
String s;
try {
while((s = in.readLine()).length() != 0)
System.out.println(s);
// An empty line terminates the program
} catch(IOException e) {
e.printStackTrace();
}
}
}