code: private byte[] read(int length) throws IOException {
      byte[] result = new byte[length];
  
      int read = 0;
      while (read < length) {
        int i = this.in.read(result, read, length - read);
        if (i == -1)
          throw new EOFException();
        read += i;
      }
  
      return result;
    }
docs: Returns a byte[] containing length valid bytes starting at offset zero.
  
  @throws EOFException If InputStream.read() returned -1 before all
  requested bytes could be read.  Note that the byte[] returned might be
  bigger then requested but will only contain length valid bytes.  The
  returned byte[] will be reused when this method is called again.