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 void
checkClosed()
Checks that the stream has not been closedvoid
close()
close this streamvoid
flush()
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 ....long
getWriteTimestamp()
boolean
isWriting()
void
setEngine(SSLEngine engine)
void
write(byte[] b, int off, int len)
write a byte array to the streamvoid
write(int b)
write a byte on to the streamprotected void
write(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 IOException
write a byte on to the stream- Specified by:
write
in 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 IOException
write a byte array to the stream- Overrides:
write
in 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 IOException
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 ....- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an error occurs while writing the data.
-
close
public void close() throws IOException
close this stream- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
checkClosed
protected void checkClosed() throws IOException
Checks 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:
isWriting
in interfaceTimeStampStream
-
getWriteTimestamp
public long getWriteTimestamp()
- Specified by:
getWriteTimestamp
in interfaceTimeStampStream
-
setEngine
public void setEngine(SSLEngine engine)
-
-