Can't figure out why simple method is infinitely looping in Java : <p>It's just a simple little method that gets user input to convert an integer from decimal to binary. It uses do-while loops to restart and verify valid input. When it catches an InputMismatchException, it starts to infinitely loop this:</p>

<pre><code>Must enter a positive integer, try again.
Enter positive integer for binary conversion:
</code></pre>

<p>I don't know why the Scanner isn't causing the program to wait for new input when I call nextInt().</p>

<p>Here's the code for the method:</p>

<pre><code>public static void main (String[] theArgs) {
    final Scanner inputScanner = new Scanner(System.in);
    boolean invalidInput = false;
    boolean running = true;
    int input = 0;
    do {
        do {
            System.out.println("Enter positive integer for binary conversion:");
            try {
                input = inputScanner.nextInt();
                if (input &lt; 1) {
                    System.out.println("Must be a positive integer, try again.");
                    invalidInput = true;
                } else {
                    invalidInput = false;
                }
            } catch (final InputMismatchException e) {
                System.out.println("Must enter a positive integer, try again.");
                invalidInput = true;
            }
        } while (invalidInput);
        System.out.println(StackUtilities.decimalToBinary(input));
        System.out.println("Again? Enter 'n' for no, or anything else for yes:");
        if (inputScanner.next().equals("n")) {
            running = false;
        }
    } while (running);
}
</code></pre>
