JDK-4093424 : java.io.BufferedReader.readLine is preventing flush of System.out (Win95)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.4
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-11-17
  • Updated: 1998-04-28
  • Resolved: 1998-04-28
Related Reports
Duplicate :  
Description

Name: rm29839			Date: 11/17/97


I am using a command line interface to prompt the
user for input; so I'm alternating outputing text and 
reading text.  I'm using a BufferedReader for 
capturing input and I've tried various output 
streams (System.out, PrintWriter, System.err)

Problem: If the user types their text and hits
'Enter' too quickly the next output prompt is not
written to the screen until all io in that
function is completed.  
If the user types their 
text and waits (about at least 3/4 second) and then
hits 'Enter' the following output prompt is 
written to the screen as expected.

In other words, if my user types as fast as I 
usually do they won't be prompted for input.
If they type in the data anyways, the BufferedReader
does still read the data just fine.  And all the 
text I sent to System.out is finally written
when the function exits.

Here is some sample code:

InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

System.out.print("Building: ");
System.out.flush();
building = br.readLine();
System.out.print("Floor: ");
System.out.flush();
floor = br.readLine();
System.out.print("Type (a or i): ");
System.out.flush();
type = br.readLine();
tCheckOut(building, floor, type);


This code works fine on WinNT, and Solaris, it only exhibits the skipped output on Win95
import java.io.*;

public class test {

  public static void main (String[] args){

    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    String floor, type, building;
    try {
      System.out.print("Building: ");
      System.out.flush();
      building = br.readLine();
      System.out.print("Floor: ");
      System.out.flush();
      floor = br.readLine();
      System.out.print("Type (a or i): ");
      System.out.flush();
      type = br.readLine();
      System.out.println(building + floor + type);
    }catch(IOException e){};
  }
}

(Review ID: 19745)
======================================================================

Comments
WORK AROUND Name: rm29839 Date: 11/17/97 I tell my users not type the 'Enter' too quickly after typing text. BTW, I've tried my program both with and without the JIT, it still fails. ======================================================================
11-06-2004

EVALUATION Probable duplicate of 4092733. -- mr@eng 1/7/1998
07-01-1998