What is the most important action you should never forget to take while developing
programs or writing documents? Saving the data, of course! It’s 3 A.M., and
you’re in the home stretch, applying the finishing touches to the term paper due
at 9 A.M. Just as you are ready to select the Print command for the final copy, it
happens. The software freezes and it won’t respond to your commands anymore.
You forgot to turn on the Autosave feature, and you have not saved the data for the
last hour. There’s nothing you can do but reboot the computer.
Data not saved will be lost, and if we ever want to work on the data again,
we must save the data to a file. We call the action of saving, or writing, data to a file
file output and the action of reading data from a file file input. Aprogram we develop
must support some form of file input and output capabilities for it to have practical
uses. Suppose we develop a program that keeps track of bicycles owned by the
dorm students. The program will allow the user to add, delete, and modify the bicycle
information. If the program does not support the file input and output features,
every time the program is started, the user must reenter the data.
In this chapter, we will introduce the classes from the java.io and javax.swing
packages that are used for file input and output operations. Also, we will show how
the two helper classes from Chapters 8 and 9—Dorm and FileManager—that provided
the file input and output support are implemented.
To learn more about the book this website supports, please visit its Information Center.