Java MT 3
The flashcards below were created by user
What are the steps to writing to a file?
Files have to be opened
– Data is then written to the file, or read from the file.
– The file must be closed prior to program termination.
How do you create an instance of the PrintWriter class?
PrintWriter outputFile = new PrintWriter("StudentData.txt");
The PrintWriter class allows you to write data to a file using the _______ & _________ methods,
What does the println method do?
place a newline character after thewritten data.
What does the print method do?
writes data without writing the newline character.
How do you pass an IO exception up the line?
need a throws clause in the method header
public static void main(String args) throws IOException
How dod you create an instance of a scanner?
Scanner keyboard = new Scanner(System.in);
Once an instance of Scanner is created, data can be read using the same methods that you have used to _______________
read keyboard input (nextLine, nextInt, nextDouble, etc).
String str = inputFile.nextLine();
The Scanner __________ method will return true if another item can be read from the file.
What Will Read until the end of the file?
Java MT 3