package com.barchart.udt.nio;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
public class NioOutputStreamUDT extends OutputStream {
protected final SocketChannelUDT channel;
protected NioOutputStreamUDT(final SocketChannelUDT channel) {
this.channel = channel;
}
@Override
public void write(final byte[] bytes, final int off, final int len)
throws IOException {
channel.write(ByteBuffer.wrap(bytes, off, len));
}
@Override
public void write(final byte[] bytes) throws IOException {
channel.write(ByteBuffer.wrap(bytes));
}
@Override
public void write(final int b) throws IOException {
final byte[] bytes = { (byte) b };
channel.write(ByteBuffer.wrap(bytes));
}
@Override
public void close() throws IOException {
channel.close();
}
}