FileDocCategorySizeDatePackage
Cleanup.javaAPI DocExample3932Mon Apr 06 18:10:24 BST 1998None

InputFile

public class InputFile extends Object

Fields Summary
private BufferedReader
in
Constructors Summary
InputFile(String fname)

    try {
      in = 
        new BufferedReader(
          new FileReader(fname));
      // Other code that might throw exceptions
    } catch(FileNotFoundException e) {
      System.out.println(
        "Could not open " + fname);
      // Wasn't open, so don't close it
      throw e;
    } catch(Exception e) {
      // All other exceptions must close it
      try {
        in.close();
      } catch(IOException e2) {
        System.out.println(
          "in.close() unsuccessful");
      }
      throw e;
    } finally {
      // Don't close it here!!!
    }
  
Methods Summary
voidcleanup()

    try {
      in.close();
    } catch(IOException e2) {
      System.out.println(
        "in.close() unsuccessful");
    }
  
java.lang.StringgetLine()

    String s;
    try {
      s = in.readLine();
    } catch(IOException e) {
      System.out.println(
        "readLine() unsuccessful");
      s = "failed";
    }
    return s;