标准输入流:
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
常调用输入方法:readLine(),String
网络编程接收字符的输出:
PrintWriter pw=new PrintWriter(socket.getOutputStream(),true));
常调用输出方法:println(Sring str),void
网络编程接收字符的输入:
BufferedReader br=new BufferedReader(newInputStreamReader(socket.getInputStream()));
常调用输入方法:readLine(),String
输出为什么不调用BufferedWriter
因为BufferedWriter没有自动刷新功能,要刷新,则调用其flush方法,它的write方法没有换行,则会在客户端与服务端之间导致阻塞。
| 输入流 | 输出流 |
抽象字节流 | InputStream | OutputStream |
常用方法 | read(byte[ ] ) | write(byte[ ]) |
常用字节流 | FileInputStream | FileOutputStream |
数据字节流 | DataInputStream(InputStream ) | DataOutputStream(OutputStream )
|
数组字节流 | ByteArrayInputStream(byte [] ) | ByteArrayOutputStream() |
|
|
|
抽象字符流 | Reader | Writer |
常用方法 | read(char[ ]) | write(char[ ]) |
常用字符流 | FileReader | FileWriter |
常用转换流 | InputStreamReader(InputStream) | OutputStreamWriter(OutputStream ) |
常用缓冲流 | BufferedReader(Reader ) | BufferedWriter(Writer ) |
|
|
|
打印字符流 | PrintWriter(OutputStream )
| 常用方法:println |
打印字节流 | PrintStream(OutputStream )
| 常用方法:println |