code: public static boolean confirmPrompt(String prompt) throws IOException {   
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String input = null;
      do {
        System.out.print(prompt + " (Y or N) ");
        input = in.readLine();
      } while (input == null
          || (!input.equalsIgnoreCase("Y") && !input.equalsIgnoreCase("N")));    
      return input.equalsIgnoreCase("Y");
    }
docs: Print out a prompt to the user, and return true if the user
  responds with "y" or "yes". (case insensitive)