According to the documentation, BufferedReader(Reader)
uses a default buffer size, while the second constructor, BufferedReader(Reader, int)
allows the buffer size to be set.
public BufferedReader(Reader in)
Creates a buffering character-input stream that uses a default-sized input buffer.
However, the docs do not not mention what the default buffer size is.
What is the default buffer size of a BufferedReader?
Initializing a BufferedReader. Wrapping the FileReader like this is a nice way to add buffering as an aspect to other readers. This will set the buffer size to 16384 bytes (16 KB). The optimal buffer size depends on factors like the type of the input stream and the hardware on which the code is running.
Every system has a different default buffer size, depending upon its configuration. Most PC-based client systems have eight kilobyte send and receive buffers, while many server-class systems have buffers of 16 kilobytes or more. It is not uncommon for high-end servers to have 32 or 48 kilobyte send and receive buffers.
stream with a default 512-byte buffer size.
BufferedReader Buffer SizeYou provide the size as a constructor parameter, like this: int bufferSize = 8 * 1024; BufferedReader bufferedReader = new BufferedReader( new FileReader("c:\\data\\input-file. txt"), bufferSize ); This example sets the internal buffer to 8 KB.
The default buffer size is 8192 characters
http://developer.android.com/reference/java/io/BufferedReader.html
BufferedReader(Reader in) Constructs a new BufferedReader, providing in with a buffer of 8192 characters.
Besides this documentation, I've extraced the rt.jar archive, and decompiled the BufferedReader.class from java.io.* using JD-GUI, this is what I found in the class definition:
private static int defaultCharBufferSize = 8192;
It isn't specified. On purpose. It's been 4096 for some years in the Sun/Oracle Java JDKs but don't rely on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With