Detailed interpretation of IO flow in Java
A stream is a series of data.
When there is data interaction between different media, Java uses stream to realize it. The data source can be a file, a database, a network or even other programs.
For example, reading the data of a file into a program is called an input stream from the perspective of the program.
Byte stream (read and write data in bytes)
InputStream byte input stream is also an abstract class. It only provides method declaration and does not provide specific implementation of methods.
FileInputStream is a subclass of InputStream. Take FileInputStream as an example to read files
OutputStream byte output stream is also an abstract class. It only provides method declarations, not specific implementations of methods
Fileoutputstream is a subclass of OutputStream. Take fileoutputstream as an example to write data
Note: if the lol file does not exist, the write operation will automatically create the file. If the directory test does not exist, an exception will be thrown.
So if the directory test does not exist, how can the program be created automatically? If the path is f: / test / Yang / lol.txt and neither test nor Yang exists?
The program obtains the directory where the file is located. If the directory does not exist, it will be created
summary
The above is all about the detailed interpretation of Java IO stream in this paper. I hope it will be helpful to you. Interested friends can continue to refer to other related topics on this site. If there are deficiencies, please leave a message to point out. Thank you for your support!