code: private void readToTmp(int length, boolean expectEnd) throws IOException {
      tmpBuffer.clear();
      tmpBuffer.limit(length);
      int read = read(tmpBuffer);
      if (read == -1 && expectEnd) {
        throw new NoSuchElementException();
      }
      if (read != length) {
        throw new CorruptDataException("Premature end of file was expecting at least: "
            + length + " but found only: " + read);
      }
      offset += read;
      tmpBuffer.flip();
    }
docs: Reads {@code length} number of bytes into {@link #tmpBuffer}. {@link #offset} is incremented
  and {@link #tmpBuffer} is flipped.
  
  @param expectEnd if end of stream encountered will throw {@link NoSuchElementException} when
  true and {@link CorruptDataException} when false.