### Question:
Hdfm { public static Hdfm read(Input di, long fileLength) throws IOException, ItlException { int hdr = di.readInt(); assertEquals("hdfm", Util.toString(hdr)); int hl = di.readInt(); int fl = di.readInt(); if (fileLength != fl) { throw new IOException("Disk file is " + fileLength + " but header claims " + fl); } int unknown = di.readInt(); int vsl = di.readUnsignedByte(); byte[] avs = new byte[vsl]; di.readFully(avs); String version = new String(avs, "us-ascii"); int consumed = vsl + 17; byte[] headerRemainder = new byte[hl - consumed]; di.readFully(headerRemainder); consumed += headerRemainder.length; if (hl != consumed) { throw new IOException("Header claims to be " + hl + " bytes but read " + consumed); } byte[] restOfFile = new byte[(int)fileLength - consumed]; di.readFully(restOfFile); byte[] decrypted = new byte[restOfFile.length]; decrypted = crypt(version, restOfFile, Cipher.DECRYPT_MODE); byte[] inflated = inflate(decrypted); boolean useCompression = !Arrays.equals(decrypted, inflated); return new Hdfm(version, unknown, headerRemainder, inflated, useCompression); } private  Hdfm(String version, int unknown, byte[] headerRemainder, byte[] fileData, Boolean compressContents); static Hdfm read(Input di, long fileLength); static Hdfm readInline(Input di, int length, int consumed); void write(DataOutput o); void write(DataOutput o, byte[] dat); final String version; final int unknown; final byte[] fileData; public Boolean compressContents; }### Answer:
@Test public void testParse6HdfmHeader() throws Exception { byte[] wholeFile = new byte[6841724]; System.arraycopy(hdfm6Header, 0, wholeFile, 0, hdfm6Header.length); Input di = new InputImpl(new ByteArrayInputStream(wholeFile)); Hdfm hdfm = Hdfm.read(di, wholeFile.length); assertNotNull(hdfm); assertEquals("6.0.4", hdfm.version); assertEquals(wholeFile.length - hdfm6Header.length, hdfm.fileData.length); }
@Test public void testParse8HdfmHeader() throws Exception { byte[] wholeFile = new byte[60699]; System.arraycopy(hdfm8Header, 0, wholeFile, 0, hdfm8Header.length); Input di = new InputImpl(new ByteArrayInputStream(wholeFile)); Hdfm hdfm = Hdfm.read(di, wholeFile.length); assertNotNull(hdfm); assertEquals("8.0", hdfm.version); assertEquals(wholeFile.length - hdfm8Header.length, hdfm.fileData.length); }