Name: bk70084 Date: 11/13/97
To reproduce this bug, enter a character and hit <Enter> as quickly as you
can afterwards.
If a bufferedReader class is created from System.in,
getLine() will occasionally block after <Enter> is
pressed, and a 2nd <Enter> has to be pressed, before the thread can continue.
Then 2 <Enters> will be seen to have been pressed.
//---------------Test.java------------------
import java.io.*;
public class Test
{
public static void main(String[] args)
{
InWindow i = new InWindow();
String s = i.cmdEnter();
System.out.println("Entered \"" + s + "\"");
}
}
class InWindow {
BufferedReader kbdstream;
InWindow()
{
kbdstream=new BufferedReader(new InputStreamReader(System.in));
}
String readLine()
{
try {
return kbdstream.readLine();
}
catch(IOException e)
{
return null;
}
}
String cmdEnter()
{
System.out.print("Enter Command, ? for help : ");
return readLine();
}
}
(Review ID: 19916)
======================================================================