IO stream summary

Java stream classification:

1. According to the flow direction:

How to distinguish the input stream from the output stream? The input stream and output stream are relative to the computer memory, so they are not relative to the source and target. For example, to read the contents of a file through Java is to read the contents of the file into the memory through the stream,

For memory, it is input, so it is called input stream, and vice versa.

2. According to the data processing unit:

Byte stream is an 8-bit general byte stream, that is, a buye, and character stream is a 16 bit Unicode character stream.

3. Classification by function:

Node flow: data can be read directly from the data source or destination.

Processing stream (wrapper stream): encapsulates other streams without directly connecting to the data source or destination. The purpose is to simplify operation and improve performance. The decorator mode in the design mode is also designed here.

Conversion stream: converts a byte stream into a character stream, which is usually used to specify the encoding format in which characters are read and written.

Finally, a diagram of the main classes of Java IO is attached:

Let's summarize the usage scenarios of various streams;

How to operate each flow is not described here. You need to practice more. The API of IO stream itself is relatively simple. The most important thing is to know what stream to use under what circumstances.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>