Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public class Login {
  static void checkPassword(String password_file) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(password_file));

    try {
      // Compare credentials
    } finally {
        try {    
          // Enclose in try-catch block
          reader.close();
        } catch (IOException ie) {
          // Forward to handler
        }
          // Other clean-up code
    }
  }

  public static void main(String[] args) throws IOException {
    String path = "password";
    checkPassword(path);
  }
}

...