title: How to avoid a "java.util.NoSuchElementException" crashing my program
body: <p>TL;DR-- how to get a java.util.NoSuchElementException to return a null instead of error and crash the program. </p>
  
  <p>I was writing a program that is supposed to read a series of ints from a text file. In the program the amount of ints will vary each time I run it. I have written a piece of code that will read ints and I want to know how to make the java.util.NoSuchElementException not crash my program and instead return a null.<br>
   The code I have writen is as follows</p>
  
  <pre><code>    public static void main(String[] args)  throws IOException{
      Scanner Input = new Scanner(new File("newestcode.txt"));
      Integer[] digits = new Integer[100];
      int h = 0;
      while(true){
          digits[h] = Input.nextInt();
          h++;
          System.out.println(digits[h]);
      }
  }
  </code></pre>
  
  <p>in case you are curious, the program I am to be writing is a sort of decryption engine for a bad encryption engine I wrote the other day </p>