Class NIOOutputStream
java.lang.Object
java.io.OutputStream
org.apache.activemq.transport.nio.NIOOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,TimeStampStream
An optimized buffered OutputStream for TCP/IP
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorNIOOutputStream(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
Modifier and TypeMethodDescriptionprotected voidChecks 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 ....longbooleanvoidvoidwrite(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 Details
-
NIOOutputStream
Constructor- Parameters:
out- the channel to write data to.
-
NIOOutputStream
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 Details
-
write
write 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
write 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
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:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an error occurs while writing the data.
-
close
close this stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
checkClosed
Checks that the stream has not been closed- Throws:
IOException
-
write
- Throws:
IOException
-
isWriting
public boolean isWriting()- Specified by:
isWritingin interfaceTimeStampStream
-
getWriteTimestamp
public long getWriteTimestamp()- Specified by:
getWriteTimestampin interfaceTimeStampStream
-
setEngine
-