List of usage examples for java.nio.channels AsynchronousFileChannel read
public abstract Future<Integer> read(ByteBuffer dst, long position);
From source file:Test.java
public static void main(String[] args) throws Exception { Path file = Paths.get("/usr/a.txt"); AsynchronousFileChannel channel = AsynchronousFileChannel.open(file); ByteBuffer buffer = ByteBuffer.allocate(100_000); Future<Integer> result = channel.read(buffer, 0); while (!result.isDone()) { ProfitCalculator.calculateTax(); }/*from w ww. ja va 2s .c o m*/ Integer bytesRead = result.get(); System.out.println("Bytes read [" + bytesRead + "]"); }