I/O Flashcards
A path that begins with a drive letter.
Absolute Path
Another word for folder
Directory
A path that does not have a drive letter prefix.
Relative Path
What is a File Class Object in Java?
Representation of file and path names
Does creating a file object create a corresponding file on your hard drive?
NO
What does the constructor for a file object take as its argument?
A String
Objects created by the JVM to signal that something is wrong in your program.
Exceptions
Which type of exception requires “exception handling”?
Checked
What is an example of a checked exception?
FileNotFoundException
ArrayIndexOutOfoundsException is an example of what kind of exception?
Unchecked
What is the keyword used to confess to the compiler?
throws
Where does an exception confession go?
Main method declaration
What is an issue of using a confession to deal with exceptions?
If the exception is thrown your program will crash.
Which is the most effective way to deal with a checked exception?
try-catch block
What are two methods we use to read a text file?
hasNext(), hasNextLine()
What is the default delimiter for hasNext()?
White space
What method changes the delimiter used by fileReader?
useDelimiter(String pattern)
What method creates an empty file?
createNewFile()
When using an absolute path to create a file, what must already exist?
The directory the file is going into.
If you want to make a directory for putting a file into, what method do you use?
getParentFile()
What object allows one to write text to a file?
PrintWriter