Differences between byte stream and byte stream

Source: Internet
Author: User

 

1. The difference between byte and char: binary encoding is used for direct transmission when word Throttling is used, and the encoding problem of the local system is involved when Byte and Char are used, some APIs in Java I/o Perform Stream Conversion Based on the parameter configurations of the operating system or JVM. This simplifies some programming processes. However, in network communication, we strongly recommend that you use byte streams to reduce various problems caused by code conversion.

2. Throttling is the most basic. All inputstream and outputstream subclasses are used to process binary data, which is processed in bytes.

However, in reality, a lot of data is text, and the concept of character stream is proposed. It is processed by the encode of the virtual machine, that is, Character Set conversion.

The two are associated through inputstreamreader and outputstreamwriter. In fact, they are associated through byte [] and string.

In actual development, the Chinese character problems are actually caused by inconsistent conversion between the primary stream and the word throttling.

When the bytes are converted to bytes streams, the bytes [] is actually converted to strings,

Public String (byte bytes [], string charsetname)

There is a key parameter character set encoding, which is usually omitted. Then the system uses the Lang of the operating system.

When the bytes stream is actually converted into byte,

Byte [] string. getbytes (string charsetname)

The same is true.

As for Java. Io, there are many other streams, mainly to improve performance and ease of use,

Such as bufferedinputstream and pipedinputstream.

3. traffic streams and word throttling are differentiated based on data processing. Byte streams are transmitted in 8 bits, and byte streams are transmitted in 16 bits.

Because the ghost stream uses the Unicode Character Set and supports multi-country text, if the stream needs to be transmitted across multiple platforms, the ghost stream should be used.

According to kilojin, the transmission efficiency of a compaction stream is higher than that of a word throttling.

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.