views:

28

answers:

1

I believe the title says it all.

I've looked at java.nio.file.attribute.Attributes and java.nio.file.FileStore, but couldn't find a way to discover the block-size of a disk-file.

A: 

Here is an article on buffer size vs I/O throughput. Synopsis: nio handles all of that for you. This SO post concludes you should use a power of 2.

Devon_C_Miller
Devon, I want a way to determine the block size programmatically that doesn't rely on conducting an experiment and interpreting the results.
Steve Emmerson
I understand that. However, there is no mechanism in Java that exposes the fielsystem's preferred IO size. Given that, the best fall back position is to use a likely multiple and trust the io/nio subsystem to do the right thing. Generally speaking, filesystems use I/O sizes of 4K, 8K, or 16K. So, using one of those sizes will generally be sufficient.
Devon_C_Miller