BufferedReader (Buffered Input)
In short: A wrapper around an input stream that collects data in an intermediate store (buffer) and thereby significantly speeds up read access, instead of directly accessing the actual source (file, network) for every single character.
In more detail: Instead of fetching every character individually from disk or the network (slow, many individual system calls), a buffered reader reads larger blocks into memory at once and returns characters or lines from it — often with a convenient method for reading an entire line at once. The counterpart for the write direction is buffered output.
In Depth
BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
String line;
while ((line = reader.readLine()) != null) {
process(line);
}
reader.close();The most obvious additional convenience of a BufferedReader over a raw input stream is the readLine() method: it returns a complete line of text at once, instead of the calling code having to search for line breaks itself — a pure byte or character stream doesn’t know the concept of “line” at all, that’s an interpretation only the BufferedReader adds.
Internally, buffering works like this: on the first read access, the BufferedReader doesn’t just fetch the one requested character, but an entire block (typically several kilobytes) from the underlying source at once and stores it in an internal array. All subsequent read accesses — as long as data still exists in the buffer — are served directly from this array, with no need to access the actual, slower source again. Only once the buffer is empty is the next block loaded.
The principle is analogous to grocery shopping: instead of making a separate trip to the supermarket for every single item (each an individual, expensive read), you buy an entire cart full at once (a large, efficient block read) and take individual items from it at home as needed (fast accesses from the local buffer).
Without buffering, processing large text files line by line especially would be extremely slow, because every single character (or at least every call) could potentially trigger an expensive access to the actual source. This is why a raw file stream is in practice almost always combined with a buffered wrapper, as soon as more than a few individual values are to be read.
See also: I/O Streams, BufferedWriter, Read Files