I want to read parts of a large file in a loop. I had to just read the entire file but that didn't work, I was getting an exception that the file is too large. I changed my code to the listing below. The code below only reads in the first chunk. What do I need to change to move to the next chunk.
final FileInputStream fis = new FileInputStream(f);
final FileChannel fc = fis.getChannel();
final long sizeRead = fc.size() < defaultReadBufferSize ? fc.size() : defaultReadBufferSize;
final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sizeRead);
while (bb.hasRemaining()) {
final CharBuffer cb = decoder.decode(bb);
this.search(f, cb);
System.out.println("============>" + cb.length());
System.out.println("============>" + bb.hasRemaining());
}
fc.close();