(Byte stream and character stream) The difference between byte stream and character stream

The difference between byte stream and character stream

At the end of output using OutputStream and Writer, the close() method is used to close the process.

If you do not use the close() method to close the output stream when using OutputStream, the content can still achieve normal output, but if you do not close the output stream when using the Writer, then it will not be output because the Writer uses the buffer. When the close() method is used, the buffer is actually forced to be refreshed, so the content will be output at this time. If it is not closed, then the output operation will not be possible. At this time, if the entire content is not closed The output can be forced to be cleared using the flush() method

The byte stream does not use the buffer when in use, and the character stream uses the buffer . In addition, the character stream using the buffer is more suitable for the processing of Chinese numbers, so in the future program development, if it involves replacing the output of Chinese, the character stream is generally used. The basic processing form of the byte stream and the character stream is identical.

Guess you like

Origin blog.csdn.net/weixin_46245201/article/details/112793587