org.entityfs.util.io
Class LockAwareFileInputStream
java.lang.Object
java.io.InputStream
java.io.FileInputStream
org.entityfs.util.io.LockAwareFileInputStream
- All Implemented Interfaces:
- Closeable
public class LockAwareFileInputStream
- extends FileInputStream
This is a FileInputStream
that keeps a reference to the read 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:
LockAwareFileInputStreamFactoryImpl
- In_jar:
- entityfs-core
Method Summary |
int |
available()
|
void |
close()
This will unlock the write lock if it is still locked by the current
thread. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
long |
skip(long n)
|
LockAwareFileInputStream
public LockAwareFileInputStream(File f,
EntityLock l)
throws FileNotFoundException
- Throws:
FileNotFoundException
LockAwareFileInputStream
public LockAwareFileInputStream(FileDescriptor fd,
EntityLock l)
LockAwareFileInputStream
public LockAwareFileInputStream(String name,
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 FileInputStream
- Throws:
IOException
available
public int available()
throws IOException
- Overrides:
available
in class FileInputStream
- Throws:
IOException
read
public int read()
throws IOException
- Overrides:
read
in class FileInputStream
- Throws:
IOException
read
public int read(byte[] b)
throws IOException
- Overrides:
read
in class FileInputStream
- Throws:
IOException
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Overrides:
read
in class FileInputStream
- Throws:
IOException
skip
public long skip(long n)
throws IOException
- Overrides:
skip
in class FileInputStream
- Throws:
IOException