CharBuffer cbuf = CharBuffer.allocate(1024 * chunkSize);
while (bufferedReader.read(cbuf) >= 0) {
Buffer buffer = cbuf.flip();
String textChunk = buffer.toString();
cache.put(textFile + (chunkId++), textChunk);
cbuf.clear();
if (chunkId % 100 == 0) System.out.printf(" Inserted %s chunks from %s into grid%n", chunkId, textFile);
}
} finally {
Util.close(in);
}