de.unkrig.commons.io
Class AsyncBufferedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
de.unkrig.commons.io.AsyncBufferedOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class AsyncBufferedOutputStream
- extends java.io.FilterOutputStream
A FilterOutputStream that forwards data asynchronously (with a background thread) to the delegate
OutputStream.
| Fields inherited from class java.io.FilterOutputStream |
out |
| Methods inherited from class java.io.FilterOutputStream |
write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AsyncBufferedOutputStream
public AsyncBufferedOutputStream(java.io.OutputStream out,
java.nio.ByteBuffer buffer,
boolean fair)
- Parameters:
buffer - Typically ByteBuffer.allocate(capacity) for a heap buffer or ByteBuffer.allocateDirect(capacity) for an off-heap bufferfair - See ReentrantLock
write
public void write(int b)
throws java.io.IOException
- Overrides:
write in class java.io.FilterOutputStream
- Throws:
java.io.IOException - The background thread got this exception
write
public void write(byte[] ba,
int off,
int len)
throws java.io.IOException
- Overrides:
write in class java.io.FilterOutputStream
- Throws:
java.io.IOException
flush
public void flush()
throws java.io.IOException
- Specified by:
flush in interface java.io.Flushable- Overrides:
flush in class java.io.FilterOutputStream
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close in interface java.io.Closeable- Overrides:
close in class java.io.FilterOutputStream
- Throws:
java.io.IOException