Class NIOOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.activemq.transport.nio.NIOOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,TimeStampStream
public class NIOOutputStream extends OutputStream implements TimeStampStream
An optimized buffered OutputStream for TCP/IP
-
-
Constructor Summary
Constructors Constructor Description NIOOutputStream(WritableByteChannel out)ConstructorNIOOutputStream(WritableByteChannel out, int size)Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckClosed()Checks that the stream has not been closedvoidclose()close this streamvoidflush()flush the data to the output stream This doesn't call flush on the underlying OutputStream, because TCP/IP is particularly efficient at doing this itself ....longgetWriteTimestamp()booleanisWriting()voidsetEngine(SSLEngine engine)voidwrite(byte[] b, int off, int len)write a byte array to the streamvoidwrite(int b)write a byte on to the streamprotected voidwrite(ByteBuffer data)-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
NIOOutputStream
public NIOOutputStream(WritableByteChannel out)
Constructor- Parameters:
out- the channel to write data to.
-
NIOOutputStream
public NIOOutputStream(WritableByteChannel out, int size)
Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.- Parameters:
out- the underlying output stream.size- the buffer size.- Throws:
IllegalArgumentException- if size <= 0.
-
-
Method Detail
-
write
public void write(int b) throws IOExceptionwrite a byte on to the stream- Specified by:
writein classOutputStream- Parameters:
b- byte to write- Throws:
IOException- if an error occurs while writing the data.
-
write
public void write(byte[] b, int off, int len) throws IOExceptionwrite a byte array to the stream- Overrides:
writein classOutputStream- Parameters:
b- the byte bufferoff- the offset into the bufferlen- the length of data to write- Throws:
IOException- if an error occurs while writing the data.
-
flush
public void flush() throws IOExceptionflush the data to the output stream This doesn't call flush on the underlying OutputStream, because TCP/IP is particularly efficient at doing this itself ....- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an error occurs while writing the data.
-
close
public void close() throws IOExceptionclose this stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
checkClosed
protected void checkClosed() throws IOExceptionChecks that the stream has not been closed- Throws:
IOException
-
write
protected void write(ByteBuffer data) throws IOException
- Throws:
IOException
-
isWriting
public boolean isWriting()
- Specified by:
isWritingin interfaceTimeStampStream
-
getWriteTimestamp
public long getWriteTimestamp()
- Specified by:
getWriteTimestampin interfaceTimeStampStream
-
setEngine
public void setEngine(SSLEngine engine)
-
-