I have the following problem, I'm working with a BufferedReader to read some lines that enter from console. The thing is that I haven't been able to figure out how to read the last line without pressing enter key. For example, using the following code
public void readEntry(){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
boolean first = true;
while(true)
{
String line = br.readLine();
if(first)
{
System.out.println();
first = false;
}
System.out.println(line);
}
}
catch (Exception e){
System.out.println(e.getMessage());}
}
And the following entry
line1
line2
line3
I get this output
line1
line2
Is there a way to indicate to the console that there is a third line, without manually pressing enter key?
Thank you!