org.entityfs.util.io
Class LockAwareOutputStream
java.lang.Object
java.io.OutputStream
org.entityfs.support.io.OutputStreamProxy
org.entityfs.util.io.LockAwareOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
public class LockAwareOutputStream
- extends OutputStreamProxy
This is an OutputStream
that keeps a reference to the write lock of
the open EFile
. It is required that the lock is held by the calling
thread when it is calling any of the methods on instances of this class. When
the stream is closed, the lock is unlocked if it is still locked.
FileDescriptor
:s and FileChannel
:s from this class are not
lock-aware.
Instances of this class are not thread safe.
- Since:
- 1.0
- Author:
- Karl Gustafsson
- See Also:
Files.openForWrite(WritableFile, EntityLock)
Method Summary |
void |
close()
This will unlock the write lock if it is still locked by the current
thread. |
void |
flush()
|
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
LockAwareOutputStream
public LockAwareOutputStream(OutputStream proxied,
EntityLock lock)
close
public void close()
throws IOException
- This will unlock the write lock if it is still locked by the current
thread.
- Specified by:
close
in interface Closeable
- Overrides:
close
in class OutputStreamProxy
- Throws:
IOException
flush
public void flush()
throws IOException
- Specified by:
flush
in interface Flushable
- Overrides:
flush
in class OutputStreamProxy
- Throws:
IOException
write
public void write(byte[] b)
throws IOException
- Overrides:
write
in class OutputStreamProxy
- Throws:
IOException
write
public void write(byte[] b,
int off,
int len)
throws IOException
- Overrides:
write
in class OutputStreamProxy
- Throws:
IOException
write
public void write(int b)
throws IOException
- Overrides:
write
in class OutputStreamProxy
- Throws:
IOException