Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scanner class and character input

 
michael delta
Ranch Hand
Posts: 35
Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why isn't scanner class an efficient way to receive input from the keyboard?Which way suits this need?
 
Greg Stevens
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just guessing here, but I think it would be because a Scanner is not buffered.
 
Greg Stevens
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this.

I just read the content of that link more carefully, and I think it might not be quite right.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only reason Scanner isn't efficient is because keyboards are slow. Scanner itself is very efficient and versatile, once you have found out about 1\n being parsed as integer 1 followed by an empty line. Scanner is a far better way to read from the keyboard than the old Reader method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic