[Switch] Java I/O flow concept analysis, java
Address: http://blog.csdn.net/yuebinghaoyuan/article/details/7388059
Streams in Java can be classified from different perspectives.
Different data streams can be divided into input streams and output streams.
Data processing units can be divided into byte streams and batch streams.
Different implementation functions can be divided into node stream and processing stream.
Output stream:
Input stream:
Therefore, both input and output are from the program perspective.
Byte stream: an 8-bit binary data is read or read at a time.
Bytes stream: A 16-bit binary data is read or read at a time.
The principle of byte stream and byte stream is the same, but the processing unit is different. The suffix is Stream, which is a byte Stream, the suffix is Reader, and Writer is a bytes Stream.
Node stream: directly connected to the data source, read or read.
It is inconvenient to directly use the node stream to read and write files. In order to read and write files faster, the stream can be processed.
Stream processing: It is used together with the node stream. Based on the node stream, it is connected to another layer.
The streams provided by Jdk inherit four categories: InputStream (byte input stream), OutputStream (byte output stream), Reader (character input stream), and Writer (character output stream ).
The following streams are commonly used in java I/O.
Byte input stream:
Byte output stream:
Character input stream:
Character output stream:
Brief Introduction:
File Operations: FileInputStream (byte input stream), FileOutputStream (byte output stream), FileReader (character input stream), FileWriter (character output stream)
Operations on pipelines: PipedInputStream (byte input stream), PipedOutStream (byte output stream), PipedReader (character input stream), and PipedWriter (character output stream)
An instance of PipedInputStream must be used together with an instance of PipedOutputStream to complete read and write operations on the pipeline. It is mainly used for thread operations.
ByteArrayInputStream, ByteArrayOutputStream, CharArrayReader, and CharArrayWriter are a byte or character array in the memory.
Buffered buffer streams: BufferedInputStream, BufferedOutputStream, BufferedReader, and BufferedWriter are processing streams with buffers. The main purpose of the buffer zone is to avoid dealing with hard disks every time and improve data access efficiency.
Conversion stream: InputStreamReader/OutputStreamWriter converts bytes into characters.
Data Stream: DataInputStream and DataOutputStream.