List of usage examples for io.netty.buffer ByteBuf nioBuffers
public abstract ByteBuffer[] nioBuffers();
From source file:org.sfs.io.AsyncFileWriterImpl.java
License:Apache License
private AsyncFileWriterImpl doWrite(Buffer buffer, long position, Handler<AsyncResult<Void>> handler) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkArgument(position >= 0, "position must be >= 0"); Handler<AsyncResult<Void>> wrapped = ar -> { if (ar.succeeded()) { if (handler != null) { handler.handle(ar);//from ww w .j av a 2 s . co m } } else { if (handler != null) { handler.handle(ar); } else { handleException(ar.cause()); } } }; ByteBuf buf = buffer.getByteBuf(); if (buf.nioBufferCount() > 1) { doWrite(buf.nioBuffers(), position, wrapped); } else { ByteBuffer bb = buf.nioBuffer(); doWrite(bb, position, bb.limit(), wrapped); } return this; }