com.twelvemonkeys.io
Class FileSeekableStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.twelvemonkeys.io.SeekableInputStream
          extended by com.twelvemonkeys.io.FileSeekableStream
All Implemented Interfaces:
Seekable, Closeable

public final class FileSeekableStream
extends SeekableInputStream

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 $
Author:
Harald Kuhr
See Also:
FileCacheSeekableStream, MemoryCacheSeekableStream, RandomAccessFile

Field Summary
 
Fields inherited from class com.twelvemonkeys.io.SeekableInputStream
markedPositions
 
Constructor Summary
FileSeekableStream(File pInput)
          Creates a FileSeekableStream that reads from the given File.
FileSeekableStream(RandomAccessFile pInput)
          Creates a FileSeekableStream that reads from the given file.
 
Method Summary
 int available()
           
 void closeImpl()
           
protected  void flushBeforeImpl(long pPosition)
          Does nothing, as we don't really do any caching here.
 boolean isCached()
          Returns true if this Seekable stream caches data itself in order to allow seeking backwards.
 boolean isCachedFile()
          Returns true if this Seekable stream caches data itself in order to allow seeking backwards, and the cache is kept in a temporary file.
 boolean isCachedMemory()
          Returns true if this Seekable stream caches data itself in order to allow seeking backwards, and the cache is kept in main memory.
 int read()
           
 int read(byte[] pBytes, int pOffset, int pLength)
           
protected  void seekImpl(long pPosition)
           
 
Methods inherited from class com.twelvemonkeys.io.SeekableInputStream
checkOpen, close, finalize, flush, flushBefore, getFlushedPosition, getStreamPosition, mark, mark, markSupported, read, reset, seek, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSeekableStream

public FileSeekableStream(File pInput)
                   throws FileNotFoundException
Creates a FileSeekableStream that reads from the given File.

Parameters:
pInput - file to read from
Throws:
FileNotFoundException - if pInput does not exist

FileSeekableStream

public FileSeekableStream(RandomAccessFile pInput)
Creates a FileSeekableStream that reads from the given file. The RandomAccessFile needs only to be open in read ("r") mode.

Parameters:
pInput - file to read from
Method Detail

isCached

public boolean isCached()
Description copied from interface: Seekable
Returns true if this Seekable stream caches data itself in order to allow seeking backwards. Applications may consult this in order to decide how frequently, or whether, to flush in order to conserve cache resources.

Returns:
true if this Seekable caches data.
See Also:
Seekable.isCachedMemory(), Seekable.isCachedFile()

isCachedFile

public boolean isCachedFile()
Description copied from interface: Seekable
Returns true if this Seekable stream 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:
true if this Seekable caches data in a temporary file.
See Also:
Seekable.isCached(), Seekable.isCachedMemory()

isCachedMemory

public boolean isCachedMemory()
Description copied from interface: Seekable
Returns true if this Seekable stream 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:
true if this Seekable caches data in main memory.
See Also:
Seekable.isCached(), Seekable.isCachedFile()

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

closeImpl

public void closeImpl()
               throws IOException
Specified by:
closeImpl in class SeekableInputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] pBytes,
                int pOffset,
                int pLength)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

flushBeforeImpl

protected void flushBeforeImpl(long pPosition)
Does nothing, as we don't really do any caching here.

Specified by:
flushBeforeImpl in class SeekableInputStream
Parameters:
pPosition - the position to flush to
See Also:
SeekableInputStream.flushBefore(long)

seekImpl

protected void seekImpl(long pPosition)
                 throws IOException
Specified by:
seekImpl in class SeekableInputStream
Throws:
IOException


Copyright © 2015. All Rights Reserved.