// write chunk size, type and data
out.write(intArray, 0, 8);
out.write(data, 0, chunkSize);
// create checksum on type and data
CRC32 checksum = new CRC32();
checksum.reset();
checksum.update(intArray, 4, 4);
checksum.update(data, 0, chunkSize);
// put checksum into byte array
ArrayConverter.setIntBE(intArray, 0, (int)checksum.getValue());
// and write it to output