-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Labels
Description
I am trying to parse binary file which begins with string (3 chars) with null termination.
The problem is, that this library requires to have prefix '3' before string, but in my binary file here is not this type of prefix.
My question how to parse string when here is no '3' prefix in front of string?
Failing error:
2021-11-09 12:50:22.141 11264-11264/com.example.binaryparser E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.binaryparser, PID: 11264
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.binaryparser/com.example.binaryparser.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.igormaznitsa.jbbp.model.JBBPAbstractField com.igormaznitsa.jbbp.model.JBBPFieldStruct.findFieldForType(java.lang.Class)' on a null object reference
Binary file structure is:
let prefix: String
let checksum: UInt32
let version: ECGFileVersion
let reserved: UInt8
let channelMask: UInt16
let sampleCount: UInt32
let frequency: UInt32
let reference: Int32
let gains: [Int32]
var samples: [Int] = [Int]()
To pars file prefix using this code:
final JBBPParser parser = JBBPParser.prepare("stringj;");
JBBPFieldStruct result = null;
try {
result = parser.parse(data);
} catch (IOException e) {
e.printStackTrace();
}
String dd = result.findFieldForType(JBBPFieldString.class).getAsString();