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

Written by kurinchilamp


Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
XML (Extensible Markup Language) Vs. CSV (Comma Separated Values)

CSV is flat file with the data separated by commas. If we needn't have to establish a relationship in the...

Close