To output one piece of binary data to a device one by one, or read one piece of binary data from a device one by one, no matter what the input/output device is, we must use a unified approach.
To complete these operations, describe them in an abstract way. This abstract description method is called the IO stream, and the corresponding abstract classes are outputstream and inputstream. Different implementation classes are replaced
Different Input and Output devices in the table are operated on bytes.
In applications, it is often necessary to output or read a piece of text with full characters. Can I use Word throttling? Everything in the computer eventually exists in a binary byte format. For the words "China"
First, get the corresponding byte, and then write the byte to the output stream. When reading, the first thing we read is the byte. But to display it as a character, we need to convert the byte into a character. By
In such a wide range of needs, people specifically provide the packaging class of the stream.
The underlying device always only accepts byte data. Sometimes, to write a string to the underlying device, you need to convert the string into bytes before writing it. The hidden stream is the packaging of byte streams, while the hidden stream is directly accepted.
String, which internally converts the string into bytes and then writes it to the underlying device, which provides a little convenience for writing or reading strings to Io settings.
When converting a character to a byte, pay attention to the encoding problem. Because the conversion of a string into a byte array is actually a certain encoding byte form of the character, reading is also the opposite principle.