This should be very simple, and I've searched Google, but didn't see anyone mentioning the issue I've noticed. Everything that I've seen does the same basic thing. Like this:
byte [] buffer = new byte[256];
int bytesRead = 0;
while((bytesRead = input.read(buffer)) != -1)
{
output.write(buffer, 0, bytesRead);
}
I know read() returns -1 when EOF is reached, but what if the file is smaller than the buffer or even the same size? Fox example, a 200 byte file is being read in. I assume it read the 200 bytes, but returns -1. That matches the javadocs, but it also means the write() is never called. I would have expected to actually tell me it read the 200 bytes, and on the next iteration to return -1.
How can I get around this "issue"?