com.ccg.io
Class FileSectionInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FileInputStream
          extended by com.ccg.io.FileSectionInputStream
All Implemented Interfaces:
Closeable

public final class FileSectionInputStream
extends FileInputStream

A InputStream which only reads from a certain section of a file.

Since:
1.0
Version:
$Revision: 1.1 $
Author:
$Author: pkb $

Constructor Summary
FileSectionInputStream(File f, long sofs, long eofs)
          Fully construct the object.
 
Method Summary
 int available()
          Determine how many bytes can be read without blocking - see InputStream.available() for details.
 int read()
          Reads next byte from file (returned as integer).
 int read(byte[] ba)
          Read collection of bytes into array.
 int read(byte[] ba, int ofs, int len)
          Read collection of bytes into array.
 long skip(long n)
          Skip over n bytes - see InputStream.skip(long) for details.
 
Methods inherited from class java.io.FileInputStream
close, finalize, getChannel, getFD
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSectionInputStream

public FileSectionInputStream(File f,
                              long sofs,
                              long eofs)
                       throws IOException
Fully construct the object.

Parameters:
f - File to read from - must not be null.
sofs - Start position in file (where read starts from). Must be in the range of 0 to the size of the file.
eofs - End position in file (where read stops). Must be in the range of 'sofs' to the size of the file.
Throws:
IOException
Since:
1.0
Method Detail

read

public int read()
         throws IOException
Reads next byte from file (returned as integer).

Overrides:
read in class FileInputStream
Returns:
-1 if EOF, otherwise integer value in range of 0-255.
Throws:
IOException

read

public int read(byte[] ba)
         throws IOException
Read collection of bytes into array.

Overrides:
read in class FileInputStream
Returns:
-1 if EOF, otherwise number of bytes actually read.
Throws:
IOException

read

public int read(byte[] ba,
                int ofs,
                int len)
         throws IOException
Read collection of bytes into array.

Overrides:
read in class FileInputStream
Returns:
-1 if EOF, otherwise number of bytes actually read.
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Skip over n bytes - see InputStream.skip(long) for details.

Overrides:
skip in class FileInputStream
Throws:
IOException

available

public int available()
              throws IOException
Determine how many bytes can be read without blocking - see InputStream.available() for details.

Overrides:
available in class FileInputStream
Throws:
IOException


Copyright 1998-1998-2006 null. All Rights Reserved.