CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Files

Text and Binary Files
Objectives

Applied

  • Write code that uses the File class to get information about a file or directory.
  • Write code that reads and writes data to a text file using buffered readers and writers.
  • Use the string handling features that were presented in chapter 12 to process text read from a delimited text file.
  • Write code that reads and writes data to a binary file using primitive data types and fixed-length strings.
  • Write code that reads and writes random-access files.
  • Given the specifications for an application that stores its data in a text or binary file, implement the program using the file handling features presented in this chapter.

Knowledge

  • Explain the differences between a text file and a binary file.
  • Explain the concept of layering and how it is used to create filtered streams that can read or write files.
  • Explain how a buffer for an output stream works and how it improves the performance of an I/O operation.
  • Name and describe the three common types of I/O exceptions.
  • Describe the functions provided by the BufferedWriter, PrintWriter, and FileWriter classes when reading data from a text file.
  • Describe the functions provided by the BufferedReader and FileReader classes when writing to text files.
  • Describe the functions provided by the DataOutputStream BufferedOutputStream, and FileOutputStream classes when writing data to a binary file.
  • Describe the functions provided by the DataInputStream, BufferedInputStream, and FileInputStream classes when reading data from a binary file.
  • List two ways that strings can be stored in a binary file and describe the difference between the techniques.
  • Explain the differences in the use of random-access and sequential-access files.
Introduction | Files and directories | File input and output | Text files | Binary files | Random-access files