title: looping over a try/catch block?
body: <p>I am trying to write a try catch block like the following, but put it inside a loop. My issue is that when i put it in a while loop, it runs x amount of times. i want it to stop when the first try is successful. but give the option to run up to 3 times. </p>
  
  <pre><code>    try {
  
              myDisplayFile();
  
          } catch (FileNotFoundException e1) {
              System.out.println("could not connect to that file..");
  
              e1.printStackTrace();
          }
  
      public static void  myDisplayFile() throws FileNotFoundException{
      Scanner kin = new Scanner(System.in);
      System.out.print("Enter a file name to read from:\t");
      String aFile = kin.nextLine();
  
      kin.close();
  
      Scanner fileData = new Scanner(new File(aFile));
      System.out.println("The file " + aFile + " contains the following lines:");
  
      while (fileData.hasNext()){
          String line = fileData.next();
          System.out.println(line);
      }//end while
      fileData.close();
  }
  </code></pre>