List of usage examples for java.nio.channels AsynchronousFileChannel write
public abstract Future<Integer> write(ByteBuffer src, long position);
From source file:Test.java
public static void main(String[] args) throws Exception { AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(Paths.get("/asynchronous.txt"), StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE); Future<Integer> writeFuture1 = fileChannel.write(ByteBuffer.wrap("Sample".getBytes()), 0); Future<Integer> writeFuture2 = fileChannel.write(ByteBuffer.wrap("Box".getBytes()), 0); int result;//w ww . j av a2 s . c om result = writeFuture1.get(); System.out.println("Sample write completed with " + result + " bytes written"); result = writeFuture2.get(); System.out.println("Box write completed with " + result + " bytes written"); }