[Soft] Imperial College IO streams Comments! java knowledge sharing!

Detailed knowledge of Java IO streams

Some people think IO knowledge is not important, it is not true, using 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, and ultimately, the IO reflect. 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 concepts

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.

flow

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.

Classification stream

Trend data can be divided according to: the input of 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 output stream

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.

Mainly by the input stream InputStream and Reader as the parent class.

Output stream is mainly composed of OutputStream and Writer as the parent class.

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, the operation byte stream 8-bit bytes,

And character streams 16 characters.

Byte stream mainly InputStream and OutputStream class as the parent.

The main character stream by the Reader and Writer as a parent.

Node process flow stream and

Node Stream (upper layer):

Write 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):

Of 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)

So that the process flow java program disregard input and output node is a disk, or other network,

As long as these nodes to process flow stream wrapper,

You can use the same input and output code to read and write data to different input and output 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.

Common input and output flow regime

io flows into categories according to the function, each function and provides a stream of bytes and character stream,

Byte stream and character stream are provided with an 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

Byte stream is IO 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 only handle 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 www.cnblogs.com/heqingxiaohuo/p/12127058.html