java knowledge sharing, IO stream Detailed!

Detailed knowledge of Java IO streams
Some people think IO knowledge is less important, is not the case, use a wide range of IO, IO can best embody the value of that data transfer over the network, especially after entering the age of the Internet, a variety of common distributed architecture , are ultimately reflected in the IO. And many manufacturers face questions will reflect the importance of the IO, including derived from the NIO, serialization like. So learn IO, it became a very important thing.
IO basic concept
IO can be simply understood as INPUT and OUT, an output representative of the input means. Input is read, the output is written.
IO can read and write data on resources, hard disk, memory, keyboard, network and so on.
Stream
IO streams in real-life equivalent, like the flow of water, a water faucet open the switch, the water flows from one end. It can be understood as each byte is arranged in order to be transmitted drops. The ordered data stream understood, transfers the data stream, in order to input and output. Data flow, the flow is directional.
Flow classification
according to data it can be divided into: the input stream, the output stream.
Per unit of data it can be divided into: byte stream, a character stream.
Press decorative pattern can be divided into: nodes stream (bottom), the processing flow (upper layer).
The input stream and the output stream of
the input stream: can read data from, but not write data to. It is typically used to read data from the network, the hard disk into memory.
Output stream: writing data only, and can not read data. It is generally used to write data from memory to the network, a hard disk.
The input stream is mainly composed of the parent class as InputStream and Reader.
Output stream mainly as OutputStream and Writer parent.
They are abstract and therefore can not create object directly.
Byte stream and character stream
Usage byte stream and character stream almost identical, except that different units are operated, operation of the 8-bit byte stream byte,
and 16-bit characters in the character stream operations.
Byte stream mainly InputStream and OutputStream class as the parent.
The main character stream by the Reader and Writer as a parent.
Process flow stream with the node
node stream (upper layer):
writing to a particular node & reading stream data. Program source connected to the actual data, and the actual input connected to the output node.
Processing flow (bottom):
for an existing connection or stream encapsulation, to implement the data stream read and write capabilities through packaging.
When using the process stream input and output, and the program does not input an actual output node, a process flow of the underlying layer of packaging made.
The same procedure may be used to access the input and output codes of different data sources. (Directed to the trim mode)
process flow so that the java program disregard input and output node is a disk, or other network,
as long as these nodes to process flow stream wrapper,
can use the same input and output code to read and write different input and output data devices.
Flow directly linked nodes for the node and the underlying physical storage, there may be differences in the physical node obtains the node streamed.
The program may be in different physical nodes into a unified flow packaging process flow,
an application to use a unified input-output code to read and write different physical storage node resources.
Input and output common system stream
io flows into categories according to the function, each function and provides a stream of bytes and character stream,
byte stream and are provided with a character stream input stream and an output stream. If the input and output is text with a character stream, if the input is the output binary content may be a byte stream.
Byte stream
IO byte stream is the most primitive way, since the data is always processed in a computer as the basic unit of byte, each byte stream is read as byte unit. Byte stream is the basis for all streams, as well as other high-premise streams. Byte stream can handle all types of data, including: music, pictures, text, video, various documents and so on. In most class "Stream" is the end of the byte stream.
Character stream
character stream can handle only text, read and write in units of characters. In most "Writer" and "Reader" is the end of the byte stream class.

Guess you like

Origin blog.51cto.com/14623707/2463484