created: 06/15/2000

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 intended 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 non-character 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 possible patterns can be formed with 8 bits?

Click Here after you have answered the question