🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17883

BufferedReader Problems

#17883
From: Kay Johnson
Date: Wed, 16 Sep 1998 00:00
23 lines
1506 bytes
I am trying to write a simple Java application for a class I am
teaching. It loops, reading in values from the keyboard using
BufferedReader. I have declared my BufferedReader as follows
    BufferedReader br = 
       new BufferedReader( new InputStreamReader( System.in ));

During the looping process, after successfully reading a few times, the
program inevitably hangs on a line that reads keyboard input. The line I
am using is
       miles = Integer.parseInt( br.readLine() );

If I keep typing values (even though the program has not yet processed
previous ones and the prompts for new input have not yet been displayed)
eventually it "unhangs" and reads in all the values entered. Since I am
trying to alternate input and output, this creates a mess!

HELP! It feels like I need to force it to read (like flush() forces a
write) but I don't see anything in my documentation about this. If this
is not the correct forum for this question, could someone please tell me
what is?? 

Thanks!
KayJ
Technical Details
Message-ID: <35FF3A4C.4E7B@ids.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b1c3ee2cbad0dcd6,start
X-Google-Attributes: gidf74b3,public
From: Kay Johnson <kayj@ids.net>
Subject: BufferedReader Problems
Date: 1998/09/16
Message-ID: <35FF3A4C.4E7B@ids.net>
X-Deja-AN: 391590551
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Organization: Community College of RI
Mime-Version: 1.0
Reply-To: kayj@ids.net
Newsgroups: borland.public.jbuilder.java.language