BufferedReader vs Scanner

Posted on

There are different classes available in java to read content of a file. Most commonly and easiest way to read a file is using BufferedReader however in certain situation it is good to use Scanner class. You can find different ways to read content of a file in our blog read a file in java. Here, we are discussing the difference between BufferedReader and Scanner classes which are listed below, helps programmers to decide between BufferedReader and Scanner class.

Difference between BufferedReader and Scanner class.

BufferedReader Scanner
BufferedReader has significantly larger buffer memory (8192 chars) Scanner has a smaller buffer (1024 chars) .
BufferedReader can only read and store String. Scanner can use tokenize using custom delimiter and parse the stream into primitive types of data.
BufferedReader throws IOException. Scanner doesn't throws IOException.
BufferedReader is synchronous and can be used for multithreaded application. Scanner isn't synchronized.So, not suitable for multithreaded application.

Stay tuned for more updates and tutorials !!!

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.