org.entityfs.util.io
Class LockAwareFileOutputStream
java.lang.Object
java.io.OutputStream
java.io.FileOutputStream
org.entityfs.util.io.LockAwareFileOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
public class LockAwareFileOutputStream
- extends FileOutputStream
This is a FileOutputStream
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:
LockAwareFileOutputStreamFactoryImpl
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)
|
LockAwareFileOutputStream
public LockAwareFileOutputStream(File f,
EntityLock l)
throws FileNotFoundException
- Throws:
FileNotFoundException
LockAwareFileOutputStream
public LockAwareFileOutputStream(File f,
boolean append,
EntityLock l)
throws FileNotFoundException
- Throws:
FileNotFoundException
LockAwareFileOutputStream
public LockAwareFileOutputStream(FileDescriptor fd,
EntityLock l)
LockAwareFileOutputStream
public LockAwareFileOutputStream(String name,
EntityLock l)
throws FileNotFoundException
- Throws:
FileNotFoundException
LockAwareFileOutputStream
public LockAwareFileOutputStream(String name,
boolean append,
EntityLock l)
throws FileNotFoundException
- Throws:
FileNotFoundException
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 FileOutputStream
- Throws:
IOException
flush
public void flush()
throws IOException
- Specified by:
flush
in interface Flushable
- Overrides:
flush
in class OutputStream
- Throws:
IOException
write
public void write(byte[] b)
throws IOException
- Overrides:
write
in class FileOutputStream
- Throws:
IOException
write
public void write(byte[] b,
int off,
int len)
throws IOException
- Overrides:
write
in class FileOutputStream
- Throws:
IOException
write
public void write(int b)
throws IOException
- Overrides:
write
in class FileOutputStream
- Throws:
IOException