zer0nes zer0nes - 1 year ago 85
Java Question

reading input till EOF in java

In C++ if I wish to read input till the EOF I can do it in the following manner


I can then run this code as ./a.out < input.txt. What is the java equivalent of this code?

Answer Source

You can do this:

Scanner s = new Scanner(System.in);
while (s.hasNextInt()) {
    A[i] = s.nextInt();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download