 <p>You could press ctrl-z (at least in Windows this works for me) but you probably don't want to do that. This would mean your program could only ever read once from the console. Better would be that you only read a line at a time rather than try to read "the whole file". Then you can just press enter to finish reading. Somthing like this:</p> <pre><code>Scanner s = new Scanner(System.in); String t = s.nextLine(); </code></pre>