code: public int read(final byte[] buffer, final int byteOffset, final int byteCount)
        throws IOException {
      IOUtils.checkOffsetAndCount(buffer, byteOffset, byteCount);
      for (int i = 0; i < byteCount; ++i) {
        int charAsInt;
        try {
          charAsInt = this.read();
          if (charAsInt == -1) {
            return i == 0 ? -1 : i;
          }
        } catch (final IOException e) {
          if (i != 0) {
            return i;
          }
          throw e;
        }
        buffer[byteOffset + i] = (byte) charAsInt;
      }
      return byteCount;
    }
docs: Reads up to {@code byteCount} bytes from this stream and stores them in the byte array
  {@code buffer} starting at {@code byteOffset}. Returns the number of bytes actually read or -1
  if the end of the stream has been reached.
  
  @throws IndexOutOfBoundsException if
  {@code byteOffset < 0 || byteCount < 0 || byteOffset + byteCount > buffer.length}.
  @throws IOException if the stream is closed or another IOException occurs.