public static AsyncOutputStream channelToOutputStream(final AsynchronousFileChannel asynchronousFileChannel) {
        notNull("asynchronousByteChannel", asynchronousFileChannel);
        return new AsyncOutputStream() {
            private int position = 0;
            @Override
            public void write(final ByteBuffer src, final SingleResultCallback<Integer> callback) {
                asynchronousFileChannel.write(src, position, null, new CompletionHandler<Integer, Object>() {
                    @Override
                    public void completed(final Integer result, final Object attachment) {
                        position += result;
                        callback.onResult(result, null);
                    }

                    @Override
                    public void failed(final Throwable exc, final Object attachment) {
                        callback.onResult(null, exc);
                    }
                });
            }

            @Override
            public void close(final SingleResultCallback<Void> callback) {
                try {
                    asynchronousFileChannel.close();
                    callback.onResult(null, null);
                } catch (IOException e) {
                    callback.onResult(null, e);
                }
            }
        };
    }
public static AsyncOutputStream channelToOutputStream(final AsynchronousFileChannel asynchronousFileChannel) {
        notNull("asynchronousByteChannel", asynchronousFileChannel);
        return new AsyncOutputStream() {
            private int position = 0;
            @Override
            public void write(final ByteBuffer src, final SingleResultCallback<Integer> callback) {
                asynchronousFileChannel.write(src, position, null, new CompletionHandler<Integer, Object>() {
                    @Override
                    public void completed(final Integer result, final Object attachment) {
                        position += result;
                        callback.onResult(result, null);
                    }

                    @Override
                    public void failed(final Throwable exc, final Object attachment) {
                        callback.onResult(null, exc);
                    }
                });
            }

            @Override
            public void close(final SingleResultCallback<Void> callback) {
                try {
                    asynchronousFileChannel.close();
                    callback.onResult(null, null);
                } catch (IOException e) {
                    callback.onResult(null, e);
                }
            }
        };
    }
public static AsyncOutputStream channelToOutputStream ( final AsynchronousFileChannel asynchronousFileChannel ) { notNull ( "asynchronousByteChannel" , asynchronousFileChannel ) ; return new AsyncOutputStream ( ) { private int position = 0 ; @ Override public void write ( final ByteBuffer src , final SingleResultCallback < Integer > callback ) { asynchronousFileChannel . write ( src , position , null , new CompletionHandler < Integer , Object > ( ) { @ Override public void completed ( final Integer result , final Object attachment ) { position += result ; callback . onResult ( result , null ) ; } @ Override public void failed ( final Throwable exc , final Object attachment ) { callback . onResult ( null , exc ) ; } } ) ; } @ Override public void close ( final SingleResultCallback < Void > callback ) { try { asynchronousFileChannel . close ( ) ; callback . onResult ( null , null ) ; } catch ( IOException e ) { callback . onResult ( null , e ) ; } } } ; }
Converts a {@link AsynchronousFileChannel} into a {@link AsyncOutputStream}

@param asynchronousFileChannel the AsynchronousFileChannel
@return the AsyncOutputStream
Converts a { @link AsynchronousFileChannel } into a { @link AsyncOutputStream }