There's a difference between the contract of read() and read(byte[]). The variable read here represents the result of read(byte[]). This is the number of bytes read from the stream. If the number of bytes read is 0, we should continue reading till we have one byte. That byte will be in buffer.