org.kc7bfi.jflac.io
Class RandomFileInputStream

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

public class RandomFileInputStream
extends InputStream

This is a FileInputStream that uses a Random Access File.

Author:
kc7bfi

Field Summary
protected  RandomAccessFile randomFile
           
 
Constructor Summary
RandomFileInputStream(File file)
          Constructor.
RandomFileInputStream(RandomAccessFile randomFile)
          Constructor.
RandomFileInputStream(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

randomFile

protected RandomAccessFile randomFile
Constructor Detail

RandomFileInputStream

public RandomFileInputStream(File file)
                      throws FileNotFoundException
Constructor.

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

RandomFileInputStream

public RandomFileInputStream(String fileName)
                      throws FileNotFoundException
Constructor.

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

RandomFileInputStream

public RandomFileInputStream(RandomAccessFile randomFile)
Constructor.

Parameters:
randomFile - The file to read
Method Detail

read

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

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

reset

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

close

public void close()
           throws IOException
Close the file.

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

markSupported

public boolean markSupported()
Is file marking supported.

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

mark

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

skip

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

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

read

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

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

read

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

Overrides:
read in class 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:
IOException - on IO error
See Also:
InputStream.read(byte[], int, int)

seek

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

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


Copyright © 2004-2011. All Rights Reserved.