title: Keep reading numbers until newline reached using a Scanner
body: <p>I want to read a couple of numbers from the console. The way I wanna do this is by having the user enter a sequence of numbers separated by a space. Code to do the following:</p>
  
  <pre><code>Scanner sc = new Scanner(System.in);
  while (sc.hasNextInt()){
      int i = sc.nextInt();
  
      //... do stuff with i ...
  }
  </code></pre>
  
  <p>The problem is, how do I stop when reaching a new line (while keeping the easy-to-read code above)? Adding a !hasNextLine() to the argument above makes it quit the loop instantly. One solution would be reading the whole line and the parse out the numbers, but I think the kinda ruins the purpose of the hasNextInt() method.</p>