2. Java IO interview

1. The difference between String encoding UTF-8 and GBK

  Answer: UTF-8 is an international code with good versatility. GBK is a national code and supports Chinese, but it is less versatile than UTF-8. However, UTF-8 occupies a large database , so the relative response speed is slower. .

2. When to use byte streams and when to use character streams

  A: All input is converted into a byte stream and then into a character stream in memory. So it is generally recommended to use character streams. But when encountering Chinese characters and garbled characters, you can use byte stream.

When saving files or transmitting on all hard disks, they are performed in bytes, including pictures, and characters are only formed in memory, so the operation using bytes is the most. of. We recommend trying to use character streams as much as possible. Once the program fails to compile successfully, you have to use byte-oriented class libraries, namely byte streams.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326018206&siteId=291194637