Java core programming-the difference between the upstream stream of IO stream and the word throttle (5), javaio
1. Differences between byte and character
A byte is 8-bit and can only contain 256 values. If it is used to represent text, it can represent ASCII code, including control characters, numbers, symbols, English letters, Western European letters, and tabs. But there are thousands of Chinese Characters in Chinese, so one byte cannot be expressed, so two bytes are used. The encoding scheme is GB2312, GBK, and Big5. Later, a unified character set emerged, which allowed every common language. Certainly, one byte was not enough.
Java uses Unicode. The char data type represents a multi-byte character. 2. Differences between byte streams and byte streams
The basic unit of 2.1 byte stream operations is byte, and the basic unit of bytes stream operations is Unicode code element.
A 2.2 byte stream does not use a buffer (memory) during operations, but directly operates with the file itself, while a swap stream uses a buffer during operations.
When operating on a file, a 2.3 byte stream can output the file even if the resource is not closed (close method). However, if the closing Stream does not use the close method, NO content will be output, this indicates that the swap stream uses a buffer and the flush method can be used to forcibly refresh the buffer. In this case, the content can be output without close.
The 2.4-byte stream is usually used to process binary data. In fact, it can process any type of data, but it does not support direct writing or reading of Unicode code elements, it supports writing and reading Unicode code elements.
3. Is it better to use Word-based throttling or volume-based stream during development?
Files are stored on all hard disks or transmitted in bytes. images are also completed in bytes, and the characters are only formed in the memory, therefore, byte operations are the most common. The primary stream reads two bytes at a time. If there are Chinese characters in it, the primary stream is used. Other general byte streams can be used. In fact, the primary stream uses the byte stream in the final analysis, because the computer only recognizes these things, it just converts them.