• Post Reply Bookmark Topic Watch Topic
  • New Topic

BufferdInputStream?

 
kedar parundekar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Complete Reference Java2 Chapter 17->
BufferdInputStream has two Constructors

BufferdInputStream(Inputsream inputStream)
BufferdInputStream(Inputsream inputStream,int bufsize)

First form creates a buffered stream using a default buffer size.
In second form, the size of the buffer is passed in bufsize.

Q1>default buffer size means how much?
Q2>If I want to read 1mb file ,then how much bufsize I should required ?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kedar parundekar:

Q1>default buffer size means how much?

It is not specified by the API, but in JDK 1.5.0_06, the buffer is defaulted to 8k:


Originally posted by kedar parundekar:

Q2>If I want to read 1mb file ,then how much bufsize I should required ?


The default buffer is a good compromise between memory use and IO throughput. If you want to experiment with the buffer size, have a look at the IO chapter of the Java Platform Performance book. It explains what the alternatives are and how to benchmark the differences in performance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!