The default buffer size for BufferedInputStream and BufferedOutputStream is 8K, and this is usually a good size.
Note. If you read Socket fast enough, you rarely get more than one package, ~ 1.5KB. If you are reading from a disk, you usually get whatever size you request, however the performance does not improve much from 32 KB to 256 KB and will probably depend on the equipment you use.
However, I also found that if you do not conduct a comparative analysis, you rarely see a noticeable difference if you use only 512 bytes as the size of the buffer (Inflator / Deflator streams), i.e. the difference may be 15% or less.
In general, you are unlikely to notice a difference in buffer sizes between 512 bytes and 32 KB. The latter is likely to be more than enough for most situations. I tend to use 256KB as I have a lot of memory and some pre-allocated buffers.
source share