Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the classification of people like Java IO?

Shulou Source: shulou.com Published: 2022-06-02 01:21:23 09月11日 Update

This article mainly shows you "what is the classification of people like Java IO". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the classification of people like Java IO?"

According to the flow direction, it is divided into input stream and output stream:

Note that the input stream and output stream are relative to the program.

Output: output the contents of the program (memory) to disk, CD and other storage devices

Input: read external data (data from disks, CDs, etc.) into the program (memory)

To sum up:

Second, according to the transmission data unit, it is divided into byte stream and character stream.

The above are also the four base streams in the Java IO stream. These four base streams are abstract classes, and the other streams inherit from these four base streams.

Third, according to the function, it is divided into node flow and packaging flow.

Node flow: you can read and write data from or to a specific place (node). Such as FileReader.

Processing flow: it is the connection and encapsulation of an existing stream, and the data is read and written through the function call of the encapsulated stream. Such as BufferedReader. The constructor of the processing flow always takes another stream object as a parameter. A stream object is wrapped multiple times by other streams and is called a link to the stream.

The template for manipulating the IO stream:

①, create source or destination object

Input: flow the data from the file to the program, where the file is the source and the program is the target

Output: flow the data from the program to the file, where the file is the target and the program is the source

②, create IO stream object

Input: creating input stream object

Output: creating output stream object

③, specific IO operation

④, close resources

Input: close () method of the input stream

Output: close () method of the output stream

Note: 1. The file IO resource opened in the program does not belong to the resource in memory, and the garbage collection mechanism cannot recycle the resource. If you do not close the resource, the file on the disk will always be referenced by the program and cannot be deleted or changed. So you should manually call the close () method to close the stream resource.

Finally, this is the overall architecture of the Java IO streams, which will be explained in more detail in the following blogs:

The above is all the content of this article "what is the Classification of Java IO?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Program output input data object file resource content method classification memory target disk article node CD function storage device device packaging Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Redmi Xiaomi Shulou Technology