31 Ocak 2018 Çarşamba

AsynchronousFileChannel Sınıfı

open metodu
Şöyle yaparız.
Path somePath = Paths.get("test.txt");
AsynchronousFileChannel channel = AsynchronousFileChannel.open(somePath,
  StandardOpenOption.READ);
read metodu
Şöyle yaparız.
ByteBuffer buf = ...;
channel.read(buf, 0, null, new CompletionHandler<Integer, Object>() {
  @Override
  public void completed(Integer bytesRead, Object attachment) {
    ...
  }

  @Override
  public void failed(Throwable exc, Object attachment) {
    ...
  }
});
write metodu
Örnek ver

Hiç yorum yok:

Yorum Gönder