code: public int checkedRead(byte[] buffer, int offset, int length) throws IOException {
  		int amountRead = read(buffer, offset, length);
  		if (amountRead == -1) {
  			throw new IOException("End of stream");
  		}
  		return amountRead;
  	}
docs: Read a number of bytes from the stream (checking that the end of the stream hasn't
  been reached).
  @param buffer the destination buffer
  @param offset the buffer offset
  @param length the length to read
  @return the amount of data read
  @throws IOException in case of I/O errors