Object Streams

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:

DataInputStream

Object Streams

You may have noticed the class ObjectOutputStream in the previous diagram. Streams of that class write objects to a destination such as a disk file. ObjectInputStream streams read objects from a source. So far in our programs objects have existed only in main memory and lasted only as long the program that created them was running. When the program stopped running (or earlier), they were garbage collected.

With an ObjectOutputStream an object can be written to disk and will remain there even after the program stops. This is the topic of object serialization, an advanced topic not covered in these notes.

QUESTION 13:

(Thought question: ) Could an object created by a program running on a Macintosh computer be transfered to a program running on a PC?