@TestInputStreamReader ,OutputStreamWriter - 图1
public void Test19() throws Exception {
InputStream in = new FileInputStream(“C:/hello.txt”);// 读取文件的数据,注意文件编码为UTF-8,防止读取乱码
// 将输入的字节流 ———转换成——> 字符流
InputStreamReader isr = new InputStreamReader(in);// 读取
char[] data = new char[1024];
int len = isr.read(data);//读取字符流中的数据,用char[]数组一次性接收
System.err.println(new String(data, 0, len));
isr.close();
}

输出流

  1. OutputStream os = socket.getOutputStream();<br /> OutputStreamWriter osw = new OutputStreamWriter(os);<br /> PrintWriter bw = new PrintWriter(osw);

输入流

        InputStream   is = socket.getInputStream();<br />            InputStreamReader isr = new InputStreamReader(is);<br />            BufferedReader reader = new BufferedReader(isr);

BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream(),”UTF-8”));
PrintWriter out = new PrintWriter(new OutputStreamWriter(s.getOutputStream(),”UTF-8”));