Getting user input without typing in a Java console
<p>I am trying to get user keyboard input but I can't seem to get it to work without using the console. </p>

<p><strong>What I am trying to achieve is to have the program to capture a user entering 12345 from the keyboard, without having to enter it in the console. And then return the integer captured.</strong></p>

<pre><code>public class InputWithoutConsoleTest {

public static void main(String[] args) {
    System.out.println(scanNumber());;
}

private static int scanNumber() {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return Integer.parseInt(br.readLine());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}
}
</code></pre>

<p><strong>Edit: The input source is a barcode scanner. It will scan a barcode and sends it to the program in the format of 1234567890{enter}. How can I capture this input in java?</strong></p>
