Kodkitabi

NIO2, Asenkron IO ve FileChannel

Blocking IO vs Non-blocking IO (NIO), Selector, Channel, Buffer, AsynchronousFileChannel ve performans avantajları. Büyük dosya işleme ve zero-copy teknikleri.

Asenkron dosya okuma örneği
AsynchronousFileChannel ch = AsynchronousFileChannel.open(path);
ByteBuffer buf = ByteBuffer.allocate(1024);
ch.read(buf, 0, buf, new CompletionHandler<Integer, ByteBuffer>() {
    public void completed(Integer result, ByteBuffer attachment) { /* ... */ }
    public void failed(Throwable exc, ByteBuffer attachment) { /* ... */ }
});