How To Read A File In Java Using BufferReader Java Interview Question And Answer

Published: 30 November 2013
on channel: Interview DOT
1,167
5

Click here -    / @interviewdot   to get notifications. How to read a file in Java -- BufferReader ? Java Interview Question And Answer

The BufferedReader class provides buffering to your Reader's. Buffering can speed up IO quite a bit. Rather than read one character at a time from the network or disk, you read a larger block at a time. This is typically much faster, especially for disk access and larger data amounts.

The main difference between BufferedReader and BufferedInputStream is that Reader's work on characters (text), wheres InputStream's works on raw bytes.

A BufferedReader is a "high-level" reader, i.e it can't connect directly to a file or input stream.

It is used to make more efficient use of low-level readers because they only read in bytes and chars whereas a BufferedReader can read Strings with the readLine() method.

br.readLine()  a method used to read characters from input stream and put them in the string in one go not byte by byte.

BufferedReader is synchronized, so read operations on a BufferedReader can safely be done from multiple threads.


On this page of the site you can watch the video online How To Read A File In Java Using BufferReader Java Interview Question And Answer with a duration of hours minute second in good quality, which was uploaded by the user Interview DOT 30 November 2013, share the link with friends and acquaintances, this video has already been watched 1,167 times on youtube and it was liked by 5 viewers. Enjoy your viewing!