O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10: Using I/O

1. Why does Java define both byte and character streams?

The byte streams are the original streams defined by Java. They are especially useful for binary I/O, and they support random-access files. The character streams are optimized for Unicode.

2. Even though console input and output is text-based, why does Java still use byte streams for this purpose?

The predefined streams, System.in, System.out, and System.err, were defined before Java added the character streams.

3. Show how to open a file for reading bytes.

Here is one way to open a file for byte input:

Image

4. Show how to open a file for reading characters.

Here is one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required