code: private void readHeader() throws IOException {
      headerBuffer.rewind();
  
      final int flgRead = in.read();
      if (flgRead < 0) {
        throw new IOException(PREMATURE_EOS);
      }
      final int bdRead = in.read();
      if (bdRead < 0) {
        throw new IOException(PREMATURE_EOS);
      }
  
      final byte flgByte = (byte)(flgRead & 0xFF);
      final LZ4FrameOutputStream.FLG flg = LZ4FrameOutputStream.FLG.fromByte(flgByte);
      headerBuffer.put(flgByte);
      final byte bdByte = (byte)(bdRead & 0xFF);
      final LZ4FrameOutputStream.BD bd = LZ4FrameOutputStream.BD.fromByte(bdByte);
      headerBuffer.put(bdByte);
  
      this.frameInfo = new LZ4FrameOutputStream.FrameInfo(flg, bd);
  
      if (flg.isEnabled(LZ4FrameOutputStream.FLG.Bits.CONTENT_SIZE)) {
        expectedContentSize = readLong(in);
        headerBuffer.putLong(expectedContentSize);
      }
      totalContentSize = 0L;
  
      // check stream descriptor hash
      final byte hash = (byte) ((checksum.hash(headerArray, 0, headerBuffer.position(), 0) >> 8) & 0xFF);
      final int expectedHash = in.read();
      if (expectedHash < 0) {
        throw new IOException(PREMATURE_EOS);
      }
  
      if (hash != (byte)(expectedHash & 0xFF)) {
        throw new IOException(DESCRIPTOR_HASH_MISMATCH);
      }
  
      maxBlockSize = frameInfo.getBD().getBlockMaximumSize();
      compressedBuffer = new byte[maxBlockSize]; // Reused during different compressions
      rawBuffer = new byte[maxBlockSize];
      buffer = ByteBuffer.wrap(rawBuffer);
      buffer.limit(0);
    }
docs: Reads the frame descriptor from the underlying {@link InputStream}.
  
  @throws IOException