I am parsing in Java a byte array having the following specification:
Trace data format:
- 4 bytes containing the Id.
- 4 bytes containing the addres
if you want to read N ASCII bytes and turn them into a String.
public static String readString(DataInputStream dis, int num) throws IOException {
byte[] bytes = new byte[num];
dis.readFully(bytes);
return new String(bytes, 0);
}
For the rest of the values, you can use
dis.readInt();
If you are asking if there is any way to know how long the strings are, I don't believe you can determine this from the information provided. Perhaps the strings are '0' byte terminated or have the length as the first byte. Perhaps if you look at the bytes in the file you will see what the format is.
od -xc my-format.bin