com.mindbright.nio
Class NonBlockingOutput

java.lang.Object
  extended by com.mindbright.nio.NonBlockingOutput

public class NonBlockingOutput
extends java.lang.Object

A non-blocking output stream.


Constructor Summary
  NonBlockingOutput(java.nio.channels.Pipe pipe)
          Creates a new NonBlockingOutput object which sends any output to a pipe.
  NonBlockingOutput(java.lang.String name)
          Creates a new NonBlockingOutput object which sends any output to a file.
protected NonBlockingOutput(Switchboard switchboard, java.nio.channels.spi.AbstractInterruptibleChannel channel)
           
 
Method Summary
protected  void clearWriteWaiting()
           
 void close()
          Close the underlying stream.
 void flush()
          Tries to flush any bytes to the underlying stream
 void write(byte[] data)
          Writes all the bytes in the provided buffer to the stream
 void write(byte[] data, int offset, int length)
          Writes the indicated part of the buffer to the stream
 void write(int data)
          Writes the specified byte
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonBlockingOutput

protected NonBlockingOutput(Switchboard switchboard,
                            java.nio.channels.spi.AbstractInterruptibleChannel channel)
                     throws java.io.IOException
Throws:
java.io.IOException

NonBlockingOutput

public NonBlockingOutput(java.nio.channels.Pipe pipe)
                  throws java.io.IOException
Creates a new NonBlockingOutput object which sends any output to a pipe.

Parameters:
pipe - Pipe to send output to
Throws:
java.io.IOException

NonBlockingOutput

public NonBlockingOutput(java.lang.String name)
                  throws java.io.IOException
Creates a new NonBlockingOutput object which sends any output to a file. Note that any write calls to this file will be blocking.

Parameters:
name - Name of file to store data in
Throws:
java.io.IOException
Method Detail

write

public void write(int data)
           throws java.io.IOException
Writes the specified byte

Throws:
java.io.IOException

write

public void write(byte[] data)
           throws java.io.IOException
Writes all the bytes in the provided buffer to the stream

Throws:
java.io.IOException

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws java.io.IOException
Writes the indicated part of the buffer to the stream

Throws:
java.io.IOException

clearWriteWaiting

protected void clearWriteWaiting()

flush

public void flush()
Tries to flush any bytes to the underlying stream


close

public void close()
           throws java.io.IOException
Close the underlying stream. It will not be possible to perform any further writes.

Throws:
java.io.IOException