NoSuchElementException error for which I have created a catch clause
<pre><code>            int num_lines = 0;
            try {
                if (file_stream.hasNextInt()) //line 81
                {
                    num_lines = file_stream.nextInt();
                }
            } catch (NoSuchElementException e) {
                System.err.println("The input is not valid and cannot be processed.");                  
            }
</code></pre>

<p>I keep getting this error even though I seem to have accounted for it in the code. The file_stream file is empty in this test case, so I wanted to see if the program would catch the error and apparently it fails to do so:</p>

<pre><code>Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at Program1.main(Program1.java:81)
</code></pre>
