April 20
Examples from April 20
Today we talked about java's classes for working with text files.
TextFileBuilder.java and SimpleInput.java This uses the FileWriter class to create a file. Lines of text are read from the keyboard with SimpleInput and written to the file.
TextFilePrinter.java This opens a text file and prints its contents usingthe FileReader class.
BetterReader.java This isn't really a better reader, but it uses the FileReader class to read through a text file one line at a time.
Copy.java and SimpleInput.java Class SimpleInput is used to get the names of a source file and a destination file. The buffered read and buffered write abilities of FileReader and FileWriter are used to copy the source into the destination with just two instructions and no loops.