When reading a file is there an advantage to using a power of 2
php
Solution
Please see this great accepted answer to this question: How do you determine the ideal buffer size when using FileInputStream?.
Most file systems are configured to use block sizes of 4096 or 8192. In theory, if you configure your buffer size so you are reading a few bytes more than the disk block, the operations with the file system can be extremely inefficient (i.e. if you configured your buffer to read 4100 bytes at a time, each read would require 2 block reads by the file system). If the blocks are already in cache, then you wind up paying the price of RAM -> L3/L2 cache latency. If you are unlucky and the blocks are not in cache yet, the you pay the price of the disk->RAM latency as well.
This is why you see most buffers sized as a power of 2, and generally larger than (or equal to) the disk block size. This means that one of your stream reads could result in multiple disk block reads - but those reads will always use a full block - no wasted reads.
Although the question is Java-related, the answer is not. Moreover it's pretty much language-agnostic. That answer covers all factors I'm aware of regarding buffer sizes.
Problem
Possible Duplicate: How do you determine the ideal buffer size when using FileInputStream? Is `fread($file, 8192)` any better or safer than `fread($file, 10000)`? Why do most examples use a power of two?