Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BufferedReader default buffer size?

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?

like image 535
FThompson Avatar asked Jun 06 '13 23:06

FThompson


People also ask

What is the default size of buffer in 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.

What is the default size of the buffer?

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.

What is the default buffer size used by any buffered class in java?

stream with a default 512-byte buffer size.

How do I find BufferedReader 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.


2 Answers

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;
like image 196
IAM Avatar answered Sep 21 '22 11:09

IAM


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.

like image 40
user207421 Avatar answered Sep 21 '22 11:09

user207421