Skip navigation links

Oracle® Multimedia Java API Reference
11g Release 2 (11.2)

E10779-01


oracle.ord.media.jai.io
Class FileSeekableInputStream

java.lang.Object
  extended by oracle.ord.media.jai.io.FileSeekableInputStream

All Implemented Interfaces:
SeekableInputStream

public class FileSeekableInputStream
extends java.lang.Object
implements SeekableInputStream

The FileSeekableInputStream implements the oracle.ord.media.io.SeekableInputStream interface to read data from a file. Forward and backward seeking are supported.


Constructor Summary
FileSeekableInputStream(java.io.File file)
          Creates a FileSeekableInputStream object that reads from a file.
FileSeekableInputStream(java.lang.String fileName)
          Creates a FileSeekableInputStream object that reads from a named file.

 

Method Summary
 void close()
          Closes the input stream and releases any resources associated with this stream.
 long getFilePointer()
          Returns the current offset in this stream.
 int read()
          Reads a single byte from the stream.
 int read(byte[] b)
          Reads data from the stream into the specified byte array, up to the length of the specified byte array.
 int read(byte[] b, int off, int len)
          Reads up to the specified number of bytes from the stream into the specified byte array starting at the starting position for the offset.
 void seek(long pos)
          Sets the file-pointer offset, measured from the beginning of the stream, at which the next read operation will occur.
 long skip(long n)
          Attempts to skip over the specified number of bytes of input.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

FileSeekableInputStream

public FileSeekableInputStream(java.io.File file)
                        throws java.io.IOException,
                               java.io.FileNotFoundException
Creates a FileSeekableInputStream object that reads from a file.
Parameters:
file - the file from which the data will be read.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.io.IOException - if an IO error occurs or if the value of the file parameter is null.

FileSeekableInputStream

public FileSeekableInputStream(java.lang.String fileName)
                        throws java.io.IOException,
                               java.io.FileNotFoundException
Creates a FileSeekableInputStream object that reads from a named file.
Parameters:
name - the name of the system-dependent file.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.io.IOException - if an IO error occurs or if the value of the name parameter is null.

Method Detail

getFilePointer

public long getFilePointer()
                    throws java.lang.Exception
Returns the current offset in this stream.
Specified by:
getFilePointer in interface SeekableInputStream
Returns:
the offset, in bytes, from the beginning of the stream at which the next read will occur.
Throws:
java.lang.Exception - if an IO error occurs.

seek

public void seek(long pos)
          throws java.lang.Exception
Sets the file-pointer offset, measured from the beginning of the stream, at which the next read operation will occur. The offset may be set beyond the end of the stream. Setting the offset beyond the end of the stream does not change the stream length; the stream length will change only by writing after the offset has been set beyond the end of the stream.
Specified by:
seek in interface SeekableInputStream
Parameters:
pos - the offset position, measured in bytes from the beginning of the stream, at which to set the file pointer.
Throws:
java.lang.Exception - if the value of the pos parameter is less than zero or if an IO error occurs.

read

public int read()
         throws java.lang.Exception
Reads a single byte from the stream.
Specified by:
read in interface SeekableInputStream
Returns:
the next byte of data as an integer (int) in the range of 0 to 255, or -1 if the end of the stream has been reached.
Throws:
java.lang.Exception - if an IO error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.lang.Exception
Reads up to the specified number of bytes from the stream into the specified byte array starting at the starting position for the offset.
Specified by:
read in interface SeekableInputStream
Parameters:
b - the buffer into which the data will be read.
off - the starting position for the offset in the byte array.
len - the maximum number of bytes to be read.
Returns:
the number of bytes read into the buffer, or -1 if the end of the BLOB was reached before any data was read.
Throws:
java.lang.Exception - if an IO error occurs.

read

public int read(byte[] b)
         throws java.lang.Exception
Reads data from the stream into the specified byte array, up to the length of the specified byte array. If the stream has fewer bytes than the length of the specified byte array, this method reads the actual number of bytes in the stream.
Specified by:
read in interface SeekableInputStream
Parameters:
b - the buffer into which the data will be read.
Returns:
the number of bytes read into the buffer, or -1 if the end of the stream was reached before any data was read.
Throws:
java.lang.Exception - if an IO error occurs.

skip

public long skip(long n)
          throws java.lang.Exception
Attempts to skip over the specified number of bytes of input.

This method may skip over some smaller number of bytes, possibly zero. This action may result from a number of conditions. For example, reaching the end of the stream before the specified number of bytes have been skipped. This method never throws an end-of-file exception.

Specified by:
skip in interface SeekableInputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
java.lang.Exception - if an IO error occurs.

close

public void close()
           throws java.lang.Exception
Closes the input stream and releases any resources associated with this stream.
Specified by:
close in interface SeekableInputStream
Throws:
java.lang.Exception - if an IO error occurs.

Skip navigation links

Oracle® Multimedia Java API Reference
11g Release 2 (11.2)

E10779-01


Copyright © 1999, 2009, Oracle and/or its affiliates. All rights reserved.