|
|
|
|
|
by _old_dude_
2524 days ago
|
|
The NIO API uses channels and buffers Path path = ...
var count = 0;
try(var channel = FileChannel.open(path)) {
var buffer = ByteBuffer.allocateDirect(8192);
while(channel.read(buffer) != -1) {
while(buffer.hasRemaining()) {
if (buffer.get() == '\n') {
count++;
}
}
buffer.clear();
}
}
System.out.println(count);
but in your particular case, i don't think there is a Gzip decoder that works on ByteBuffer. |
|