CHAPTER 23 — File I/O with Scanner and PrintStream

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: 03/19/2006

CHAPTER 23 — File I/O with Scanner and PrintStream

This chapter discusses how to use the Scanner class for input from files and how to use the PrintStream class for output to files.

This chapter is optional. Except for chapter 24, disk I/O is not much used again until it is taken up in more detail in chapter 80. However, most interesting programs do some disk I/O, and reading this chapter may enable you to write some of them.

Chapter Topics:

  • Using Scanner with disk files.
  • I/O Exceptions
  • hasNext Methods of Scanner
  • Class PrintStream
  • print() and println() Methods of PrintStream

QUESTION 1:

In our past programs, what input stream has been used with Scanner ?