• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a Character

 
Christian Long
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, Hello, I need to make a simple 'Choice' that require a character as input. Example:


The problem here is that, if the user does not input anything & press [Enter] directly, There will still be a "System.in.read();" remaining (forcing him to press [Enter] again).. This can complicate many things..

So, I would like to know if its possible to use some sort of buffer (like 'BufferedInputStream') & to read a single character - as effectively as possible..
The only thing I know with buffer is the BufferedReader .readLine.. for reading a Line (String).
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just use BufferedReader.readLine?
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or java.util.Scanner
 
Christian Long
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thnx.This topic may be closed.
I found that I could simply use '.read()' method with either BufferedReader or BufferedInputStream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!