Skip to content

Instantly share code, notes, and snippets.

@kylelong
Created October 17, 2019 02:17
Show Gist options
  • Save kylelong/3473c34d3056b6d988985cb4248f8591 to your computer and use it in GitHub Desktop.
Save kylelong/3473c34d3056b6d988985cb4248f8591 to your computer and use it in GitHub Desktop.
BinaryParser
import java.io.*;
import java.nio.ByteBuffer;
public class BinaryParser {
/**
* byte array Byte buffer
* @param args
*/
public static void main(String[] args) {
try {
long offset = 0;
RandomAccessFile raf = new RandomAccessFile(args[0], "r");
while(offset < raf.length()) {
byte [] records = new byte[32];
byte [] pid = new byte[8];
raf.read(records);
raf.read(pid);
ByteBuffer buffer = ByteBuffer.wrap(records);
System.out.println(new String(records));
raf.seek(10);
offset += 8;
raf.seek(offset);
}
// }
}
catch (FileNotFoundException e) {
System.err.println("Could not file file: " + args[0]);
}
catch (IOException e) {
System.err.println("Writing error: " + e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment