Last active
January 19, 2022 15:05
-
-
Save karussell/83d5987b83c72b46eac81f18f544a760 to your computer and use it in GitHub Desktop.
read header entries of any file from GraphHopper without dependencies
This file contains 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.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