When reading from InputStreams, how do you decide what size to use for the byte[]?
int nRead;
byte[] data = new byte[16384]; // <-- this number is the o
In that situation, I always use a reasonable power of 2, somewhere in the range of 2K to 16K. In general, different InputStreams will have different optimal values, but there is no easy way to determine the value.
In order to determine the optimal value, you'd need to understand more about the exact type of InputStream you are dealing with, as well as things like the specifications of the hardware that are servicing the InputStream.
Worrying about this is probably a case of premature optimization.