Package com.twelvemonkeys.io
Class FileCacheSeekableStream.FileCache
- java.lang.Object
-
- com.twelvemonkeys.io.AbstractCachedSeekableStream.StreamCache
-
- com.twelvemonkeys.io.FileCacheSeekableStream.FileCache
-
- Enclosing class:
- FileCacheSeekableStream
static final class FileCacheSeekableStream.FileCache extends AbstractCachedSeekableStream.StreamCache
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.RandomAccessFile
cacheFile
-
Constructor Summary
Constructors Constructor Description FileCache(java.io.File pFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
close()
long
getPosition()
Returns the current cache read/write position.int
read()
Reads a single byte a the current read/write position.int
read(byte[] pBuffer, int pOffset, int pLength)
Writes a series of bytes at the current read/write position.void
seek(long pPosition)
Repositions the current cache read/write position to the given position.void
write(byte[] pBuffer, int pOffset, int pLength)
Writes a series of bytes at the current read/write position.void
write(int pByte)
Writes a single byte at the current read/write position.-
Methods inherited from class com.twelvemonkeys.io.AbstractCachedSeekableStream.StreamCache
flush
-
-
-
-
Method Detail
-
write
public void write(int pByte) throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Writes a single byte at the current read/write position. The read/write position will be increased by one.- Specified by:
write
in classAbstractCachedSeekableStream.StreamCache
- Parameters:
pByte
- the byte value to write.- Throws:
java.io.IOException
- if an I/O exception occurs in the cache backing mechanism.
-
write
public void write(byte[] pBuffer, int pOffset, int pLength) throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Writes a series of bytes at the current read/write position. The read/write position will be increased bypLength
.This implementation invokes
AbstractCachedSeekableStream.StreamCache.write(int)
pLength
times. Subclasses may override this method for performance.- Overrides:
write
in classAbstractCachedSeekableStream.StreamCache
- Parameters:
pBuffer
- the bytes to write.pOffset
- the starting offset into the buffer.pLength
- the number of bytes to write from the buffer.- Throws:
java.io.IOException
- if an I/O exception occurs in the cache backing mechanism.
-
read
public int read() throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Reads a single byte a the current read/write position. The read/write position will be increased by one.- Specified by:
read
in classAbstractCachedSeekableStream.StreamCache
- Returns:
- the value read, or
-1
to indicate EOF. - Throws:
java.io.IOException
- if an I/O exception occurs in the cache backing mechanism.
-
read
public int read(byte[] pBuffer, int pOffset, int pLength) throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Writes a series of bytes at the current read/write position. The read/write position will be increased bypLength
.This implementation invokes
AbstractCachedSeekableStream.StreamCache.read()
pLength
times. Subclasses may override this method for performance.- Overrides:
read
in classAbstractCachedSeekableStream.StreamCache
- Parameters:
pBuffer
- the bytes to writepOffset
- the starting offset into the buffer.pLength
- the number of bytes to write from the buffer.- Returns:
- the number of bytes read, or
-1
to indicate EOF. - Throws:
java.io.IOException
- if an I/O exception occurs in the cache backing mechanism.
-
seek
public void seek(long pPosition) throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Repositions the current cache read/write position to the given position.- Specified by:
seek
in classAbstractCachedSeekableStream.StreamCache
- Parameters:
pPosition
- the new read/write position- Throws:
java.io.IOException
- if an I/O exception occurs in the cache backing mechanism.
-
getPosition
public long getPosition() throws java.io.IOException
Description copied from class:AbstractCachedSeekableStream.StreamCache
Returns the current cache read/write position.- Specified by:
getPosition
in classAbstractCachedSeekableStream.StreamCache
- Returns:
- the current cache read/write postion.
- Throws:
java.io.IOException
- if the position can't be determined because of a problem in the cache backing mechanism.
-
close
void close() throws java.io.IOException
- Specified by:
close
in classAbstractCachedSeekableStream.StreamCache
- Throws:
java.io.IOException
-
-