The difference between a character stream and a byte stream (RPM)

Source: Internet
Author: User

The difference between a character stream and a byte stream is  
A) The number of bytes per read is different B) The former is buffered, the latter is not
C) The former is a character read-write, the latter is a byte read-write D) There is no difference between the two, which can be used interchangeably with

 

Java stream operations are divided into byte stream and character stream. The main difference between a byte stream and a character stream is the way they are handled
Byte stream is the most basic, all inputstream and OutputStream subclasses are, mainly used in processing binary data, it is processed by bytes. But in fact, a lot of data is text, and put forward the concept of character stream, it is the virtual machine encode to deal with, that is, to do character set conversion
between the two through Inputstreamreader,outputstreamwriter to associate, is actually associated with byte[] and string. The problem of Chinese characters appearing in the actual development of

is actually caused by the non-unification between the character stream and the stream of bytes.

Byte stream----> Character stream
bytes flow into a character stream, which is actually byte[] converted to string,
public String (byte bytes[], string charsetname)
There is a key parameter character set encoding, which is usually omitted, and the system uses the operating system's Lang
character stream----> byte flow

 

Common sense:

For GBK encoding standard, English occupies 1 bytes, Chinese occupies 2 bytes
for UTF-8 encoding standard, English occupies 1 bytes, Chinese occupies 3 bytes
For Unicode encoding standards, English Chinese is 2 bytes. This is also what is called Unicode

 

Reprint address: http://dylanxu.iteye.com/blog/1322066

Character stream differs from Byte stream (EXT)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.