Results 1 to 2 of 2
- 08-19-2009, 07:44 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
Need help in knowing how to clear buffer.
I'm trying to iterate over some statements until the user enters the letter 'n'.
Java Code:char answer; BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
I need to find a way to clear the buffer so that the character that gets entered does not interfere with the input statements inside the loop. Thanks.Java Code:do { .... //statements. System.out.print("Continue? y/n _ "); answer = (char) BR.next(); }while (answer != 'n');
- 08-20-2009, 05:02 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
There is no direct way to do this in Java. If you are worried about the memory and stuff, nothing to do there. Garbage collector will keep free the unnecessary memory allocations in your application. There is no guarantee each time, but 90% it's fine.
What you mean by this?
Similar Threads
-
Knowing which IP address is active
By sukatoa in forum NetworkingReplies: 2Last Post: 05-05-2009, 04:01 PM -
Need Help: Double Buffer
By rukawa527 in forum AWT / SwingReplies: 1Last Post: 02-09-2009, 12:39 AM -
Buffer
By QPRocky in forum NetworkingReplies: 2Last Post: 02-02-2009, 03:54 PM -
Help with String Buffer
By mathias in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:52 AM -
how to set the value of BUFFER SIZE
By oregon in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 03:16 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks