1. The inheritance relationship of streams, as well as byte streams and character streams.
2. Node streams FileOutputStream and FileInputStream and processing streams BufferedInputStream and BufferedOutputStream. And the corresponding FileOutputWriter, FileInputReader, BufferedInputReader, BufferedOutputWriter.
3. Convert streams InputStreamReader and OutputStreamWriter
1: Stream inheritance relationship
Byte stream
Character stream
Usage scope of character stream and byte stream: Byte stream is generally used to process images, videos, and PPT, Word type files . Character streams are generally used to process plain text files, such as TXT files, etc. Byte streams can be used to process plain text files, but character streams cannot be used to process non-text files such as images and videos.
2: Processing streams BufferedReader, BufferedWriter, BufferedInputStream
BufferedOutputsStream must include the upper layer of node streams. In other words, the processing stream is based on the node stream. The stream with Buffered is also called a buffered stream. The buffered stream processes the input and output of files the fastest. Therefore, buffered streams are generally used more frequently.
The following are two simple examples of file copying:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 twenty one twenty two twenty three twenty four 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
Three: Conversion stream InputStreamReader and OutputStreamWriter
The role of conversion stream, when the text file is stored in the form of byte stream on the hard disk, After reading through InputStreamReader, it is converted into a character stream for processing by the program. The character stream processed by the program is converted into a byte stream through OutputStreamWriter and saved.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 twenty one twenty two twenty three twenty four 25 26 27 28 29 30 31 32 |
|
Related articles:
Java IO stream output stream OutputString() use
Java's comprehensive introduction to IO stream
Related videos:
The latest Java complete video tutorial-free online video tutorial
The above is the detailed content of About IO streams in Java: stream inheritance relationships, processing streams, and conversion streams. For more information, please follow other related articles on the PHP Chinese website!