Read multiple lines from console in Java, issue with last line
<p>I want to load multiple lines from console. I paste text into console, this text has more lines. Last line doesn't want to load, its because there is missing \n. I am not able to add \n in console, because when I paste it, it runs immediately. Another issue is that while doesn't want to end. It loads everything expect last line and doesn't end.</p>

<pre><code>        Scanner input = new Scanner(System.in); 
        List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
        String lineNew;

        while (input.hasNextLine()) {
            lineNew = input.nextLine();
            System.out.println(lineNew);
            lines.add(lineNew);         
        }
</code></pre>