Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Scanner vs. BufferedReader in terms of file reading  RSS feed

 
sheng liang
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simply put, comparing Scanner and BufferedReader, which one is more efficient in runtime while reading from a file?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wasn't able to find a difference. Generally they're both limited by the speed of file access; other details are irrelevant as far as performance is concerned. You may discover one performs better than the other in certain situations, or maybe on certain platforms, but in general there's no significant performance difference. More importantly, Scanner has a lot more useful methods, and is easier to use. I doubt I will ever use BufferedReader again in code for JDK 5+.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!