public byte read()
{
if (position < maxByte)
{
// The byte can be read from the buffer
// In Java, the bytes are always signed.
return (byteBuffer[position++]);
}
else if (isEOFInBuffer)
{
// EOF is reached
position = maxByte + 1; // Set position to EOF
throw new System.IO.EndOfStreamException();
}
else
{
// End of the buffer is reached
readNewBuffer(offset + position);
return read();
}
}