BufferedReader still needs something from keyboard
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   gil_dan
Posted On:   Wednesday, March 17, 2004 09:28 AM

hi, i'm building a simple command-line chat program. i use BufferedReader(InputStreamReader(System.in)) to read from keyboard. let's call this object typeIn. when i end the program...i will close all the IO streams and sockets before exiting the program. but i have a slight problem...it seems that typeIn will not close until i press Enter. here's wat i did... System.out.print("Closing typeIn..."); if(typeIn!=null) typeIn.close(); System.out.println("done"); is there any way i can "insert" an Enter character without pressing on the keyboard? i dun wanna affect the print statements in between the typeIn.close() statement.    More>>

hi, i'm building a simple command-line chat program.
i use BufferedReader(InputStreamReader(System.in)) to read from keyboard. let's call this object typeIn.

when i end the program...i will close all the IO streams and sockets before exiting the program.
but i have a slight problem...it seems that typeIn will not close until i press Enter.

here's wat i did...

			
System.out.print("Closing typeIn...");
if(typeIn!=null) typeIn.close();
System.out.println("done");


is there any way i can "insert" an Enter character without pressing on the keyboard? i dun wanna affect the print statements in between the typeIn.close() statement.


thx,

gildan2020

   <<Less

Re: BufferedReader still needs something from keyboard

Posted By:   Stephen_Ostermiller  
Posted On:   Friday, March 19, 2004 01:55 PM

have you tried an typeIn.interrupt() call?
About | Sitemap | Contact