Working with (Text) Files Flashcards
When reading text files using the Scanner, and using a method other than nextLine(), what characters are used, by default, to separate tokens (tokens are each individual item that the scanner gets)?
Spaces (e.g. “ “)
New lines (e.g. “\n” )
Carriage return (e.g. “\r” )
True or False?
A programmer may specify a specific character that should be used to separate tokens in a text file being read by the scanner.
True
If a user were to delete a file that the Scanner was to use, then an error would occur. What is the formal name for an error of this kind?
Exception
If a piece of code, intended to read a file from disk using a Scanner, is not placed in a try-catch block, what would happen if it could not read the file due to it having been moved by the user?
The programme will crash
What single import statement could be used instead of the ones shown here:
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.file.*
The default behavior of Files.write() is to …
Hint, Caused an issue on assignment 2!
Overwrite any existing file with the same name.