Source:
public PcapNgFile(Path filePath) throws BadPcapFileException, IOException { super(filePath); ByteOrder byteOrder; PcapTimestampScale timeStampPrecision = PcapTimestampScale.MICROSECOND; TreeMap<Long, Long> fileIndex = getFileIndex(); setCurrentRank(0); SeekableByteChannel fileChannel = getFileChannel(); int magicNumber; ByteBuffer header = ByteBuffer.allocate(PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); header.clear(); header.order(ByteOrder.LITTLE_ENDIAN); fileChannel.read(header); header.flip(); int blockType = header.getInt(); if (blockType != PcapFileValues.PCAPNG_SHB) { this.close(); throw new BadPcapFileException(String.format("%04x", blockType) + " Missing Section Header Block."); } ENDIAN as byte order as shown int headerLen = header.getInt(); header = ByteBuffer.allocate(headerLen - PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); header.order(ByteOrder.LITTLE_ENDIAN); header.clear(); fileChannel.read(header); header.flip(); magicNumber = header.getInt(); switch (magicNumber) { case PcapFileValues.MAGIC_LITTLE_ENDIAN_NG: byteOrder = ByteOrder.LITTLE_ENDIAN; break; case PcapFileValues.MAGIC_BIG_ENDIAN_NG: byteOrder = ByteOrder.BIG_ENDIAN; break; default: this.close(); throw new BadPcapFileException(String.format("%04x", magicNumber) + " is not a pcapNg endian type."); } header.order(byteOrder); int majorVersion = ConversionHelper.unsignedShortToInt(header.getShort()); int minorVersion = ConversionHelper.unsignedShortToInt(header.getShort()); fileIndex.put(getCurrentRank(), fileChannel.position()); setCurrentRank(getCurrentRank()); init(byteOrder, majorVersion, minorVersion, timeStampPrecision); }

Target:
public PcapNgFile(Path filePath) throws BadPcapFileException, IOException { super(filePath); ByteOrder byteOrder; PcapTimestampScale timeStampPrecision = PcapTimestampScale.MICROSECOND; TreeMap<Long, Long> fileIndex = getFileIndex(); setCurrentRank(0); SeekableByteChannel fileChannel = getFileChannel(); int magicNumber; ByteBuffer header = ByteBuffer.allocate(PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); header.clear(); header.order(ByteOrder.LITTLE_ENDIAN); fileChannel.read(header); header.flip(); int blockType = header.getInt(); if (blockType != PcapFileValues.PCAPNG_SHB) { this.close(); throw new BadPcapFileException(String.format("0x%08x", blockType) + " Missing Section Header Block."); } ENDIAN as byte order as default int headerLen = header.getInt(); ENDIAN as if (headerLen > 0xFF) { header.flip(); header.order(ByteOrder.BIG_ENDIAN); header.getInt(); headerLen = header.getInt(); } header = ByteBuffer.allocate(headerLen - PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); header.clear(); fileChannel.read(header); header.flip(); magicNumber = header.getInt(); switch (magicNumber) { case PcapFileValues.MAGIC_LITTLE_ENDIAN_NG: byteOrder = ByteOrder.BIG_ENDIAN; break; case PcapFileValues.MAGIC_BIG_ENDIAN_NG: byteOrder = ByteOrder.LITTLE_ENDIAN; break; default: this.close(); throw new BadPcapFileException(String.format("%08x", magicNumber) + " is not a pcapNg endian type."); } header.order(byteOrder); int majorVersion = ConversionHelper.unsignedShortToInt(header.getShort()); int minorVersion = ConversionHelper.unsignedShortToInt(header.getShort()); fileIndex.put(getCurrentRank(), fileChannel.position()); setCurrentRank(getCurrentRank()); init(byteOrder, majorVersion, minorVersion, timeStampPrecision); }