CHAPTER 83 — Writing Text Files

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: June 6, 2000; revised: 07/07/2002, 08/06/2002, 06/08/2006

CHAPTER 83 — Writing Text Files

This chapter explains how to create a text file on the hard disk and how to write character data to it.

Chapter Topics:

  • Class FileWriter
  • Creating a disk file
  • Closing a disk file
  • The write() method
  • Catching IO exceptions
  • Class BufferedWriter

In chapter 21 you used redirection to write text files. This told the operating system to create a file and to send your program's output to it. In this chapter your program has control of file creation and writes output to it.

QUESTION 1:

(Review: ) What is the ancestor class of all streams that do character-oriented output?