code: public int readFrom(InputStream stream) throws IOException {
          int bytesRead = stream.read(buffer);
          if (bytesRead < 0) {
              bytesInBuffer = 0;
          } else {
              bytesInBuffer = bytesRead;
          }
          return bytesRead;
      }
docs: Reads from the input stream.
  @param stream the input stream to read from
  @throws IOException I/O error when reading from buffer
  @return bytes read from buffer