org.blinkenbyte.io
Class ReadWriteDevice.RWDOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.blinkenbyte.io.ReadWriteDevice.RWDOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Enclosing interface:
ReadWriteDevice

public static class ReadWriteDevice.RWDOutputStream
extends java.io.OutputStream

Implementation of an OutputStream wrapped around a ReadWriteDevice.


Field Summary
protected  boolean isClosed
          Flag indicating if this stream has been closed.
 ReadWriteDevice rwd
          The ReadWriteDevice being wrapped.
 
Constructor Summary
ReadWriteDevice.RWDOutputStream(ReadWriteDevice _rwd)
          Constructs a new RWDOutputStream from a ReadWriteDevice.
 
Method Summary
 void close()
          Closes this stream (but not the underlying ReadWriteDevice).
 void flush()
          Flushes this stream.
protected  void throwIfClosed()
          Convenience method to throw an exception if the stream has been closed.
 void write(byte[] b)
          Writes b.length bytes from array b to the stream.
 void write(byte[] b, int offset, int len)
          Writes len bytes from array b at offset b[offset] to the stream.
 void write(int b)
          Writes a single byte to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rwd

public ReadWriteDevice rwd
The ReadWriteDevice being wrapped.


isClosed

protected boolean isClosed
Flag indicating if this stream has been closed.

Constructor Detail

ReadWriteDevice.RWDOutputStream

public ReadWriteDevice.RWDOutputStream(ReadWriteDevice _rwd)
Constructs a new RWDOutputStream from a ReadWriteDevice.

Method Detail

throwIfClosed

protected void throwIfClosed()
                      throws java.io.IOException
Convenience method to throw an exception if the stream has been closed.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes this stream (but not the underlying ReadWriteDevice).

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flushes this stream.

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

write

public void write(int b)
           throws java.io.IOException
Writes a single byte to the stream.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes from array b to the stream.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int offset,
                  int len)
           throws java.io.IOException
Writes len bytes from array b at offset b[offset] to the stream.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException