CHAPTER 85 — Writing to Binary Files



created: 06/15/2000; revised 07/08/02; 06/09/03

CHAPTER 85 — Writing to Binary Files

The character-oriented streams (Readers and Writers)
translate data between an internal 16-bit format and
an external UTF format.
This is convenient for many applications.
However, this translation is not appropriate for
non-character data.
This chapter discusses OutputStream and its subclasses
which are used for general-purpose output.

Chapter Topics:

  • Binary Files.
  • OutputStream
  • FileOutputStream
  • BufferedOutputStream
  • DataOutputStream
    • writeInt()
    • writeDouble()
    • writeBytes()
  • Hexadecimal file dumps.

Most data types use all the bit patterns that can be formed
with the eight bits of a byte.
A file that contains such data is often called a
binary file.
A byte from a binary file might hold any possible pattern.
(A byte from an ASCII text file is restricted to somewhat
less than half of the possible patterns).

QUESTION 1:


(Review: ) How many patterns can be formed using 8 bits?