FileDocCategorySizeDatePackage
FileImageInputStream.javaAPI DocAndroid 1.5 API3237Wed May 06 22:41:54 BST 2009javax.imageio.stream

FileImageInputStream

public class FileImageInputStream extends ImageInputStreamImpl
The FileImageInputStream class implements ImageInputStream and obtains its input data from a File or RandomAccessFile.
since
Android 1.0

Fields Summary
RandomAccessFile
raf
The raf.
Constructors Summary
public FileImageInputStream(File f)
Instantiates a new FileImageInputStream from the specified File.

param
f the File of input data.
throws
FileNotFoundException if the specified file doesn't exist.
throws
IOException if an I/O exception has occurred.

        if (f == null) {
            throw new IllegalArgumentException("f == null!");
        }

        raf = new RandomAccessFile(f, "r");
    
public FileImageInputStream(RandomAccessFile raf)
Instantiates a new FileImageInputStream from the specified RandomAccessFile.

param
raf the RandomAccessFile of input data.

        if (raf == null) {
            throw new IllegalArgumentException("raf == null!");
        }

        this.raf = raf;
    
Methods Summary
public voidclose()

        super.close();
        raf.close();
    
public longlength()

        try {
            return raf.length();
        } catch (IOException e) {
            return -1L;
        }
    
public intread()

        bitOffset = 0;

        int res = raf.read();
        if (res != -1) {
            streamPos++;
        }
        return res;
    
public intread(byte[] b, int off, int len)

        bitOffset = 0;

        int numRead = raf.read(b, off, len);
        if (numRead >= 0) {
            streamPos += numRead;
        }

        return numRead;
    
public voidseek(long pos)

        if (pos < getFlushedPosition()) {
            throw new IndexOutOfBoundsException();
        }

        raf.seek(pos);
        streamPos = raf.getFilePointer();
        bitOffset = 0;