Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.5k points)

As far I know, the two most common methods of reading character-based data from a file in Java is using Scanner or BufferedReader. I also know that the BufferedReader read files efficiently by using a buffer to avoid physical disk operations. My questions are:

  • Does Scanner performs as well as BufferedReader?
  • Why would you choose Scanner over BufferedReader or vice versa?

1 Answer

0 votes
by (46k points)
The scanner is utilized for parsing symbols from the contents of the stream while BufferedReader just shows the stream plus does not do any specific parsing.

You can pass a BufferedReader to a scanner as the origin of characters to parse.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 29, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 13, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer
asked Sep 29, 2019 in Java by Shubham (3.9k points)

Browse Categories

...