The stream in Java is an abstract concept. When the program needs to read data from a certain data source, it will open a data stream. The data source can be a file, memory or network, etc.
On the contrary, when you need to write data to a data source destination, a data stream will also be opened. , the data source destination can also be a file, memory or network, etc.
A stream is a set of sequential bytes with a starting point and an ending point. It is a general term or abstract for data transmission. That is, the transmission of data between two devices is called a stream. (Recommended study: java course)
The essence of a stream is data transmission. The stream is abstracted into various classes according to the data transmission characteristics to facilitate more intuitive data operations.
Streams in Java can be classified from different perspectives:
According to the direction of the stream: It is divided into input stream and output stream.
According to the different processing data units: is divided into byte stream (8 bits) and character stream (16 bits).
According to different functions: It is divided into node flow and processing flow.
Node stream: is a stream (such as file, memory) that can read and write data from a specific data source (node). It's like a single pipe is connected to a faucet and starts discharging water.
Processing stream: is "connected" to an existing stream (node stream or processing stream), and provides the program with more powerful reading and writing functions by processing data. It is like connecting a pipe (node flow) and adding several thicker pipes (processing flow) with special functions to further process the outflowing water.
The four basic streams InputStream, OutputStream, Reader, and Writer each have more specific subclasses, which are divided into file stream, buffer stream, data stream, conversion stream, Print stream, Object stream, etc., all of which are respectively Specific functions or used to operate specific data
The above is the detailed content of what is stream in java. For more information, please follow other related articles on the PHP Chinese website!