OutputStream

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

An OutputStream handles byte data.

OutputStream

OutputStream is an abstract class from which all byte-oriented output streams are derived. Its descendant classes are used for general-purpose (non-character output). These streams are aimed at writing groups of 8-bit bytes to output destinations. The bytes are in the same format as Java primitive types. For example, 4-byte groups corresponding to type int can be written to a disk file.

Java Output streams

We will mostly be interested in FileOutputStream and DataOutputStream. We have used PrintStream many times already, because System.out is an object of that type.

QUESTION 12:

Say that you wrote 32-bit int data to a disk file using DataOutputStream. What input stream class would another program use to read that file?