Created
October 17, 2019 02:17
-
-
Save kylelong/3473c34d3056b6d988985cb4248f8591 to your computer and use it in GitHub Desktop.
BinaryParser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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