How do you determine the ideal buffer size when using FileInputStream?

后端 未结 9 1866
北海茫月
北海茫月 2020-11-22 17:01

I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from t

9条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 17:45

    You could use the BufferedStreams/readers and then use their buffer sizes.

    I believe the BufferedXStreams are using 8192 as the buffer size, but like Ovidiu said, you should probably run a test on a whole bunch of options. Its really going to depend on the filesystem and disk configurations as to what the best sizes are.

提交回复
热议问题