Data in a file remains after program execution ends.
True
A statement opening a text file for reading or writing may generate a FileNotFoundException
.
True
Which of the following is the correct way to open a text file called “myfile.txt
” for reading?
1 inputStream = new Scanner(new File("myfile.txt"));
Which Java class is the preferred class to use for reading from a text file?
Scanner
Which of the following is not a method of the File
class?
1 close()
What is the difference between a full path name and a relative path name?
A full path name starts at the root directory while a relative path name starts at the directory in which the program is running.
Which Java class is the preferred class to use for writing to a text file?
PrintWriter
Which of the following statements opens a text file called “myfile.txt
” so that new text can be appended to the existing contents of the file?
1 outputStream = new PrintWriter(new FileOutputStream("myfile.txt", true));
The close
method of the PrintWriter
class must be called inside of a try
block.
False
What is the difference between an input stream and an output stream?
An input stream reads data from a file or console and sends it to a program. An output stream takes data from a program and writes it to a file or console.
What is the difference between a text file and a binary file?
A text file stores a sequence of characters while a binary file uses some other encoding of data.
A comma-separated values or CSV file is a simple text format used to store a list of records.
True