Created
October 9, 2014 14:06
-
-
Save standy66/89726e008e26954ad46d to your computer and use it in GitHub Desktop.
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
channel = new FileInputStream(dbFilePath).getChannel(); | |
ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); | |
try { | |
while (buffer.remaining() > 0) { | |
int keySize = buffer.getInt(); | |
byte[] key = new byte[keySize]; | |
buffer.get(key); | |
int valueSize = buffer.getInt(); | |
byte[] value = new byte[valueSize]; | |
buffer.get(value); | |
cache.put(new String(key, "UTF-8"), new String(value, "UTF-8")); | |
} | |
} catch (BufferUnderflowException e) { | |
System.err.println("Corrupted file"); | |
System.exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment