Java MT 3

  1. 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.
  2. How do you create an instance of the PrintWriter class?
    PrintWriter outputFile = new PrintWriter("StudentData.txt");
  3. The PrintWriter class allows you to write data to a file using the _______ & _________ methods,

  4. What does the println method do?
    place a newline character after thewritten data.
  5. What does the print method do?
    writes data without writing the newline character.
  6. 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
  7. How dod you create an instance of a scanner?
    Scanner keyboard = new Scanner(;
  8. 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();
  9. The Scanner __________ method will return true if another item can be read from the file.
  10. What Will Read until the end of the file?

    while (___________()){
Card Set
Java MT 3
MT 3