title: use scanner to store lines to an array
body: <p>I need to copy the data which I have and then paste it to the java Eclipse Console output window, this data contains some lines and there is a word in each line. I don't know how many lines it has.
  How could I store the lines in an array? I tried this code but after pasting the data, I should press the keyboard <strong>Enter</strong> key two times. It also stores the even lines (Not all lines). How may I fix it? Thanks</p>
  
  <pre><code>import java.util.ArrayList;
  
  import java.util.Scanner;
  
  public class SCAN {
  
      public static void main(String[] args) {
          ArrayList&lt;String&gt; lines = new ArrayList&lt;String&gt;();
          Scanner s = new Scanner(System.in);
          while(s.hasNextLine()){
              String line = s.nextLine();
              if(line.length() &gt; 0) {
                  lines.add(s.nextLine());
              } else {
                  break;
              }
          }
          System.out.println(lines);
  }
  }
  </code></pre>