What are the advantages of character streams over byte streams?

relative to a text file:

The

byte stream reads bytes and uses the corresponding transcoding to get the original content.

The

character stream also reads bytes, but after a layer of conversion, for example, bytes that were originally saved in utf-8 code will be converted to Unicode code. And then use a variety of different codes to convert.

1. The latter talks about converting the local code to unicode,. How do you do that? what you save locally may be gbk,utf-8.. How to change to unicode?
2. What are the advantages of the latter compared with the former? I think the "can be converted to a variety of different codes for unicode" is really flexible. You can turn whatever you want after you get the Unicode code. Anything else?

Mar.24,2021

Stream is for bytes, and Writer/Reader is for characters
. In fact, the essence of Writer/Reader is InputStreamReader or OutputStreamWriter
is actually wrapped in a layer, which is more convenient to use. For example, readLine this function
will use default encoding when the code is not specified. For example, the system default UTF8, does not specify the encoding to read GBK files directly.

Menu