title: Unspecified number of lines for input in Java using scanner
body: <p>I am trying to make a program that finds the maximum sum through an input that looks something like this:</p>
  
  <p>5 &lt;-this is the number of rows.<br>
  1<br>
  2 3<br>
  1 5 7<br>
  9 1 1 2<br>
  8 5 4 13 2  </p>
  
  <p>But the amount of triangles is unknown. I need to take an input from the console, but I don't know how to see if there is anything left to be input.</p>
  
  <p>In better words. How do I scan the System.in, an input that could be </p>
  
  <p>2<br>
  18<br>
  430 302<br>
  6<br>
  102<br>
  76 76<br>
  268 153 185<br>
  492 480 112 405<br>
  286 436 126 25 391<br>
  390 32 399 76 29 174  </p>
  
  <p>or maybe just</p>
  
  <p>2<br>
  18<br>
  430 302  </p>
  
  <p>I know that if I use scan.hasNext() it will block if there isn't anything next. All the numbers for the input could possibly be entered all at once.</p>