com.barchart.udt.nio.NioOutputStreamUDT Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Network Show documentation
Show all versions of Network Show documentation
Encrypted, high-performance, and event-driven/reactive network stack for Java 11+
/**
* Copyright (C) 2009-2013 Barchart, Inc.
*
* All rights reserved. Licensed under the OSI BSD License.
*
* http://www.opensource.org/licenses/bsd-license.php
*/
package com.barchart.udt.nio;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
/**
* {@link OutputStream} for UDT sockets.
*/
public class NioOutputStreamUDT extends OutputStream {
protected final SocketChannelUDT channel;
/**
* Creates a new UDT output stream.
*
* @param channel
* The UDT socket 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 {
// Just cast it -- this is the same thing SocketOutputStream does.
final byte[] bytes = { (byte) b };
channel.write(ByteBuffer.wrap(bytes));
}
@Override
public void close() throws IOException {
channel.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy