Rajat Saxena
Rajat Saxena

Reputation: 3935

Java byte streams and character streams

From Java Docs:

The Console object also provides input and output streams that are true character streams, through its reader and writer methods.

Why should I care if the underlying stream is a byte stream or a character one? I know that in byte stream it read one byte at a time and in character streams it reads a character at a time which can be of many bytes according to the specifics of the machine(? correct me if I'm wrong).

Upvotes: 0

Views: 69

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533910

Why should I care if the underlying stream is a byte stream or a character one?

Because bytes are for binary data and characters are for text data. If you read a character like € it will be just one characters even though if you read it a byte at a time it could 3 bytes or not depending on the encoding.

Upvotes: 1

Related Questions