What is the difference between character stream and byte stream?

Firstly, I know the difference between a character and a byte. a character is a signature or remark of something ("A", "δΈ­" or another), a byte is a specific size on a computer. And the size of the character on the computer depends on the coding style. But what is a character stream and a byte stream? What specific type are they worth? Is a byte stream a stream of bytes? if so, what is a character stream? My last question is: what type of TCP transport stream?

+6
source share
5 answers

Character Stream is a higher level concept than Byte Stream. A character stream is, in fact, a stream of bytes that has been wrapped in logic that allows it to derive characters from a specific encoding; as opposed to reading bytes and decoding the characters that they represent.

+13
source

An InputStream reads bytes and Reader reads characters.

Everything over TCP will be in bytes. If you know that a byte stream represents characters, you can use InputStreamReader to use InputStream as a Reader.

+4
source

TCP, of course, transfers bytes. What these bytes represent is consistent with the protocol.

Here you can read about the relationship between character and byte streams: http://docs.oracle.com/javase/tutorial/i18n/text/stream.html

In practice, a character stream is an abstraction on the application side over a byte stream, allowing you to read / write bytes to or from characters using different encodings.

0
source

Look at this:

and I assume TCP transport packets, a stream of bytes.

0
source

character classes in java are used to handle character input and output for unicode ex-hadles, while bytestream classes are used to handle input and output bytes, that is, only for ascii codes. The first was used in java 1.0, and later was used in java 1.1

0
source

Source: https://habr.com/ru/post/903375/


All Articles