org.kc7bfi.jflac.io
Class RandomFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.kc7bfi.jflac.io.RandomFileInputStream
All Implemented Interfaces:
java.io.Closeable

public class RandomFileInputStream
extends java.io.InputStream

This is a FileInputStream that uses a Random Access File.


Constructor Summary
RandomFileInputStream(java.io.File file)
          Constructor.
RandomFileInputStream(java.io.RandomAccessFile randomFile)
          Constructor.
RandomFileInputStream(java.lang.String fileName)
          Constructor.
 
Method Summary
 void close()
          Close the file.
 void mark(int arg0)
           
 boolean markSupported()
          Is file marking supported.
 int read()
          Read a byte value.
 int read(byte[] buffer)
          Read bytes into an array.
 int read(byte[] buffer, int pos, int bytes)
          Read bytes into an array.
 void reset()
           
 void seek(long pos)
          Seek to a position in the file.
 long skip(long bytes)
          Skip bytes in the input file.
 
Methods inherited from class java.io.InputStream
available
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomFileInputStream

public RandomFileInputStream(java.io.File file)
                      throws java.io.FileNotFoundException
Constructor.

Parameters:
file - The File to read
Throws:
java.io.FileNotFoundException - If file is not found

RandomFileInputStream

public RandomFileInputStream(java.lang.String fileName)
                      throws java.io.FileNotFoundException
Constructor.

Parameters:
fileName - The name of the file to read
Throws:
java.io.FileNotFoundException - If the file is not found.

RandomFileInputStream

public RandomFileInputStream(java.io.RandomAccessFile randomFile)
Constructor.

Parameters:
randomFile - The file to read
Method Detail

read

public int read()
         throws java.io.IOException
Read a byte value.

Specified by:
read in class java.io.InputStream
Returns:
the byte value
Throws:
java.io.IOException - on IO error
See Also:
InputStream.read()

reset

public void reset()
Overrides:
reset in class java.io.InputStream
See Also:
InputStream.reset()

close

public void close()
           throws java.io.IOException
Close the file.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - on IO error
See Also:
InputStream.close()

markSupported

public boolean markSupported()
Is file marking supported.

Overrides:
markSupported in class java.io.InputStream
Returns:
true if file marking is supported
See Also:
InputStream.markSupported()

mark

public void mark(int arg0)
Overrides:
mark in class java.io.InputStream
See Also:
InputStream.mark(int)

skip

public long skip(long bytes)
          throws java.io.IOException
Skip bytes in the input file.

Overrides:
skip in class java.io.InputStream
Parameters:
bytes - The number of bytes to skip
Returns:
the number of bytes skiped
Throws:
java.io.IOException - on IO error
See Also:
InputStream.skip(long)

read

public int read(byte[] buffer)
         throws java.io.IOException
Read bytes into an array.

Overrides:
read in class java.io.InputStream
Parameters:
buffer - The buffer to read bytes into
Returns:
bytes read
Throws:
java.io.IOException - on IO error
See Also:
InputStream.read(byte[])

read

public int read(byte[] buffer,
                int pos,
                int bytes)
         throws java.io.IOException
Read bytes into an array.

Overrides:
read in class java.io.InputStream
Parameters:
buffer - The buffer to read bytes into
pos - The start position in the buffer
bytes - The number of bytes to read
Returns:
bytes read
Throws:
java.io.IOException - on IO error
See Also:
InputStream.read(byte[], int, int)

seek

public void seek(long pos)
          throws java.io.IOException
Seek to a position in the file.

Parameters:
pos - The seek position
Throws:
java.io.IOException - On error seeking