Example usage for io.netty.channel ChannelOutboundBuffer nioBuffers

List of usage examples for io.netty.channel ChannelOutboundBuffer nioBuffers

Introduction

In this page you can find the example usage for io.netty.channel ChannelOutboundBuffer nioBuffers.

Prototype

public ByteBuffer[] nioBuffers() 

Source Link

Document

Returns an array of direct NIO buffers if the currently pending messages are made of ByteBuf only.

Usage

From source file:io.nodyn.netty.pipe.NioOutputStreamChannel.java

License:Apache License

@Override
protected void doWrite(final ChannelOutboundBuffer in) throws Exception {
    this.process.getEventLoop().submitBlockingTask(new Runnable() {
        public void run() {
            ByteBuffer[] buffers = in.nioBuffers();
            for (int i = 0; i < buffers.length; ++i) {
                ByteBuffer each = buffers[i];
                int amount = each.limit() - each.position();
                byte[] bytes = new byte[amount];
                each.get(bytes);//from   w  w w. j  a  v a 2s.c  o  m
                try {
                    NioOutputStreamChannel.this.out.write(bytes);
                } catch (IOException e) {
                    NioOutputStreamChannel.this.process.getNodyn().handleThrowable(e);
                }
            }
        }
    });
}