Chapter Summary
Files that are considered to be strings of characters and that look like characters to your program and to a text editor are called text files. All other files are called binary files.
Your program can use the class
PrintWriterto write to a text file and can use the classScannerto read from a text file.When reading from a file, you should always check for the end of a file and do something appropriate if the end of the file is reached. The way you test for the end of a file depends on whether your program is reading from a text file or a binary file.
You can read a file name from the keyboard into a variable of type
Stringand use that variable in place of a file name.The class
Filecan be used to see whether an existing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access