org.apache.activemq.transport.nio
Class NIOOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.activemq.transport.nio.NIOOutputStream
All Implemented Interfaces:
Closeable, Flushable, TimeStampStream

public class NIOOutputStream
extends OutputStream
implements TimeStampStream

An optimized buffered outputstream for Tcp


Constructor Summary
NIOOutputStream(WritableByteChannel out)
          Constructor
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.
 
Method Summary
protected  void checkClosed()
          Checks that the stream has not been closed
 void close()
          close this stream
 void flush()
          flush the data to the output stream This doesn't call flush on the underlying outputstream, because Tcp is particularly efficent 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 stream
protected  void write(ByteBuffer data)
           
 void write(int b)
          write a byte on to the stream
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NIOOutputStream

public NIOOutputStream(WritableByteChannel out)
Constructor

Parameters:
out -

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 class OutputStream
Parameters:
b - - byte to write
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
write a byte array to the stream

Overrides:
write in class OutputStream
Parameters:
b - the byte buffer
off - the offset into the buffer
len - the length of data to write
Throws:
IOException

flush

public void flush()
           throws IOException
flush the data to the output stream This doesn't call flush on the underlying outputstream, because Tcp is particularly efficent at doing this itself ....

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
close this stream

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
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 interface TimeStampStream

getWriteTimestamp

public long getWriteTimestamp()
Specified by:
getWriteTimestamp in interface TimeStampStream

setEngine

public void setEngine(SSLEngine engine)


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.