Java Reference
In-Depth Information
8
Handling Input and Output
What you Will learn in this chapter:
How input and output differ
How to handle interaction with users in your programs
How to store and load information in files
Wrox.com code doWnloads for this chapter
The wrox.com code downloads for this chapter are found at www.wrox.com/go/
beginningjavaprogramming on the Download Code tab. The code is in the Chapter 8
download and individually named according to the names throughout the chapter.
So far, all the programs you've been writing throughout the course of this topic have operated
more or less on their own, without much interaction with the user at runtime, meaning that
the interaction with the program happened while you were coding it, i.e. specifying all the
tasks the program should perform. Once it ran, however, the program just went its course.
Interaction in programming is described as “input/output” (I/O). Of course, this communica-
tion flows in two directions, one in the form of “output,” which is information the program
provides to outside parties, and the other in the form of “input,” which is information users
provide to the program or information the program reads in from the outside world. It is easy
to imagine a multitude of cases where such functionality could be useful. Imagine a program
asking the user's name, for instance, or a program asking if it should terminate or ignore an
error when something unexpected happens. These aspects are all covered in this chapter.
Interaction can happen not only between a program and a human end user, but can also
involve other sources of information. Consider, for example, the fact that so far, whenever you
closed and restarted a program, all its previous data values were lost. When writing a budget
tracking application, you cannot expect your users to leave the program running indefinitely
(what if the power goes out?) or expect them to re-enter all the information once they reopen
 
Search WWH ::




Custom Search