Skip to content

Instantly share code, notes, and snippets.

@karussell
Last active January 19, 2022 15:05
Show Gist options
  • Save karussell/83d5987b83c72b46eac81f18f544a760 to your computer and use it in GitHub Desktop.
Save karussell/83d5987b83c72b46eac81f18f544a760 to your computer and use it in GitHub Desktop.
read header entries of any file from GraphHopper without dependencies
import java.io.RandomAccessFile;
class ReadGHFile {
public static void main(String[] args) throws Exception {
String name = args[0];
RandomAccessFile raFile = new RandomAccessFile(name, "r");
raFile.seek(0);
if (raFile.length() == 0) throw new IllegalArgumentException("empty file " + name);
String versionHint = raFile.readUTF();
if (!"GH".equals(versionHint)) throw new IllegalArgumentException("Not a GraphHopper file! Expected 'GH' as file marker but was " + versionHint);
System.out.println("bytes: " + raFile.readLong());
System.out.println("seg size:" + raFile.readInt());
for (int i = 0; i < 20; i++) {
System.out.println(i+"\t: " + raFile.readInt());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment