• Associate a low-level input (i.e., FileInputStream) or output (i.e., FileOutputStream) stream with a File object
  • Describe how low-level file I/O works (i.e., reading or writing of byte data, importance of the sequence of data)
  • Describe how high-level (DataOutputStream and DataInputStream) file I/O works (i.e., methods for reading and writing of primitive data types, association with low-level stream, the importance of the sequence of data)
  • Explain why it is important to close a stream when file operations are complete
  • Use the try-with-resources construct to ensure resources are closed appropriately
  • Explain what the PrintWriter class is used for
  • Read text data from a file using Scanner objects
  • Use the Files class to read/write text files
  • Explain the difference between binary and text files

Note taking requirement

Don't forget to submit your notes in Canvas by midnight Wednesday.

Reading

Intro [4:48]

  • Describe how streams allow data to flow into or out from your program.
  • What type(s) of data are FileInputStream and FileOutputStream designed to process?
  • How are file streams similar to / different from System.in and System.out?
  • What does a Path represent?
  • How do you create a Path object?

File IO Streams [5:03]

  • How are the OutputStream and FileOutputStream related?
  • Give an example of a specific type of InputStream.
  • What methods are available to read from an input stream? How do they differ?
  • Why is it unlikely that we will use FileInputStreams to read from a file?
  • Take a look at the FileOutputStream Javadoc to see how it parallels the FileInputStream.

High Level IO (primitives) [6:31]

  • What class is DataInputStream's parent?
  • What is a decorator/wrapper class?
  • What methods are available to read from an input stream? How do they differ?
  • Take a look at the DataOutputStream Javadoc to see how it parallels the DataInputStream.
  • What does it mean if a method is marked deprecated?

Text IO [2:22]

  • What classes are used to read and write text?

Object IO [5:40]

  • What method is used to write an object to an ObjectOutputStream?
  • What interface must be implemented to make an object capable of being written out as an object?
  • What is a checked exception?
  • What must you do to deal with a checked exception?

Code Sample of Raw IO [14:29]

  • What type of exception may be thrown by Files.newOutputStream()?
  • Why does test.raw look strange when loaded in IntelliJ?
  • What does the finally block do?
  • When does it make sense to use try-with-resources?