Class FileSeekableStream
java.lang.Object
java.io.InputStream
com.twelvemonkeys.io.SeekableInputStream
com.twelvemonkeys.io.FileSeekableStream
- All Implemented Interfaces:
Seekable, Closeable, AutoCloseable
A
SeekableInputStream implementation that uses random access directly to a File.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/FileSeekableStream.java#4 $
- See Also:
-
Field Summary
FieldsFields inherited from class SeekableInputStream
closed, flushedPosition, markedPositions, position -
Constructor Summary
ConstructorsConstructorDescriptionFileSeekableStream(File pInput) Creates aFileSeekableStreamthat reads from the givenFile.FileSeekableStream(RandomAccessFile pInput) Creates aFileSeekableStreamthat reads from the given file. -
Method Summary
Modifier and TypeMethodDescriptionintInputStreamvoidprotected voidflushBeforeImpl(long pPosition) Does nothing, as we don't really do any caching here.booleanisCached()SeekablebooleanReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in a temporary file.booleanReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in main memory.intread()intread(byte[] pBytes, int pOffset, int pLength) protected voidseekImpl(long pPosition) Methods inherited from class SeekableInputStream
checkOpen, close, finalize, flush, flushBefore, getFlushedPosition, getStreamPosition, mark, mark, markSupported, read, reset, seek, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
mRandomAccess
-
-
Constructor Details
-
FileSeekableStream
Creates aFileSeekableStreamthat reads from the givenFile.- Parameters:
pInput- file to read from- Throws:
FileNotFoundException- ifpInputdoes not exist
-
FileSeekableStream
Creates aFileSeekableStreamthat reads from the given file. TheRandomAccessFileneeds only to be open in read ("r") mode.- Parameters:
pInput- file to read from
-
-
Method Details
-
isCached
public boolean isCached()Seekable- Returns:
trueif thisSeekablecaches data.- See Also:
-
isCachedFile
public boolean isCachedFile()Description copied from interface:SeekableReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in a temporary file. Applications may consult this in order to decide how frequently, or whether, to flush in order to conserve cache resources.- Returns:
trueif thisSeekablecaches data in a temporary file.- See Also:
-
isCachedMemory
public boolean isCachedMemory()Description copied from interface:SeekableReturns true if thisSeekablestream caches data itself in order to allow seeking backwards, and the cache is kept in main memory. Applications may consult this in order to decide how frequently, or whether, to flush in order to conserve cache resources.- Returns:
trueif thisSeekablecaches data in main memory.- See Also:
-
available
InputStream- Overrides:
availablein classInputStream- Throws:
IOException
-
closeImpl
- Specified by:
closeImplin classSeekableInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
flushBeforeImpl
protected void flushBeforeImpl(long pPosition) Does nothing, as we don't really do any caching here.- Specified by:
flushBeforeImplin classSeekableInputStream- Parameters:
pPosition- the position to flush to- See Also:
-
seekImpl
- Specified by:
seekImplin classSeekableInputStream- Throws:
IOException
-