2012 October 07

Java: Buffered Reader Vs. Scanner

Buffered Reader
– Buffered reader reads text from a character input stream and buffers those characters
– Buffered reader has a buffer size of 8 KB
– Buffered reader is synchronized and can be safely called from multiple threads
– To parse for primitive data types additional functions needs to be called

Scanner
– Scanner breaks down input into tokens and translates individual tokens according to their data type
– Scanner has a buffer size of 1KB
– Scanner is not synchronized
– Scanner can parse for primitive types and strings using regular expressions

Source:
http://docs.oracle.com/javase/6/docs/api/java/io/BufferedReader.html
http://docs.oracle.com/javase/tutorial/essential/io/scanning.html

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn