Page 635 - Introduction to Programming with Java: A Problem Solving Approach
P. 635

                  CHAPTER
15
   Files
Objectives
• Become acquainted with classes in the java.io package. • Learn how to write text and data to a text file.
• Learn how to read text and data from a text file.
• Use text file I/O in a data translation activity.
• Understand the differences between text and binary file formats.
• Learn how to write and read primitive values to and from binary files.
• Learn the use of a data file header.
• Learn how to write and read objects to and from Java object files. Apago PDF Enhancer
• Use the API File class to gather information about a specified file.
• Implement GUI file chooser functionality with the API JFileChooser class.
Outline
15.1 Introduction
15.2 JavaAPIClassesYouNeedtoImport
15.3 Text-FileOutput
15.4 Text-FileInput
15.5 HTMLFileGenerator
15.6 TextFileDataFormatVersusBinaryFileDataFormat 15.7 BinaryFileI/O
15.8 ObjectFileI/O
15.9 TheFileClass
15.10 GUITrack:TheJFileChooserClass(Optional) 15.1 Introduction
Up until now, all program input has come from the keyboard and all output has gone to the computer screen. But that type of input/output (I/O) is temporary. When you send output to the computer screen, it’s not saved. A day later, if you want to display it again, you have to run the program again. Likewise, when you
   601










































































   633   634   635   636   637