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
ConstructorDescriptionConstructorNIOOutputStream
(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 void
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
boolean
void
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 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:
write
in 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:
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
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
close this stream- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
checkClosed
Checks that the stream has not been closed- Throws:
IOException
-
write
- Throws:
IOException
-
isWriting
public boolean isWriting()- Specified by:
isWriting
in interfaceTimeStampStream
-
getWriteTimestamp
public long getWriteTimestamp()- Specified by:
getWriteTimestamp
in interfaceTimeStampStream
-
setEngine
-