What is the buffer size in BufferedReader?

后端 未结 3 2013
面向向阳花
面向向阳花 2020-12-05 05:10

What is the sense of buffer size in the constructor?

BufferedReader(Reader in, int size)

As i have written the program:

imp         


        
3条回答
  •  我在风中等你
    2020-12-05 05:43

    http://www.docjar.com/html/api/java/io/BufferedReader.java.html

    As per this java documentation, default buffer size is 8192 characters capacity. Line size is considered as 80 chars capacity.

    8192 buffer size is sufficient for smaller file sizes. But again this is growable. if file contains more than 8192 characters, then fill method of bufferedreader will increase the buffer size before reading content from file. For bigger content files preferably set your own max size to buffer while creating buffered reader through constructor, so that you can avoid recreating memory and copying the old array into newly created array.

提交回复
热议问题