CHAPTER 21 — Files and File Output

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 home page   go to next page        

Created: 01/14/99; revised: 08/13/99, 01/20/00, 07/13/02, 05/21/03, 03/19/06, 08/31/08

CHAPTER 21 — Files and File Output

Files are extremely useful, since often the data for a program comes from a file and often the results are stored in a file. You already know about files since you have been creating and using files in following these notes (and probably in your other work, as well). This chapter discusses how to send the output of a program to a file.

Chapter Topics:

  • Idea of a file
  • Text files
  • Redirecting output to a text file

The next chapter discusses how to read data from a file. For a full discussion of file I/O you will have to wait until much later in these notes.

QUESTION 1:

What is a file? (Try to think of a one sentence definition.)