There are two more questions you face :)
Partial / Truncated / Corrupted Data Analysis
, Kaitai Struct .ksy , . , , , . , , . EOFException, , - .
, , , " " - .. . : " " , ( ), ( ).
Kaitai Struct - --debug. , , (void _read()). , . , :
Btssnoop b = Btssnoop.fromFile("/path/to/file.bin");
System.out.println(b.packets.size());
, --debug, :
Btssnoop b = Btssnoop.fromFile("/path/to/file.bin");
b._read();
System.out.println(b.packets.size());
try/catch IOException:
Btssnoop b = Btssnoop.fromFile("/path/to/file.bin");
try {
b._read();
} catch (IOException e) {
System.out.println("warning: truncated packets");
}
System.out.println(b.packets.size());
:
--debug Java, v0.3; , git , , .--debug , , , /. , " /" --debug - , .- , , . , , , .
NPE
Java enums, -
this.pet1 = Animal.byId(_io.readU4le());
Animal.byId :
private static final Map<Long, Animal> byId = new HashMap<Long, Animal>(3);
static {
for (Animal e : Animal.values())
byId.put(e.id(), e);
}
public static Animal byId(long id) { return byId.get(id); }
Java null , . null - ( ) true false. , NPE, .. , ?