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

FileImageOutputStream

public class FileImageOutputStream extends ImageOutputStreamImpl
The FileImageOutputStream class implements ImageOutputStream and writes the output data to a File or RandomAccessFile.
since
Android 1.0

Fields Summary
RandomAccessFile
file
The file.
Constructors Summary
public FileImageOutputStream(File f)
Instantiates a new FileImageOutputStream with the specified File.

param
f the output File.
throws
FileNotFoundException if the file not found.
throws
IOException if an I/O exception has occurred.

        this(f != null ? new RandomAccessFile(f, "rw") : null);
    
public FileImageOutputStream(RandomAccessFile raf)
Instantiates a new FileImageOutputStream with the specified RandomAccessFile.

param
raf the output RandomAccessFile.

        if (raf == null) {
            throw new IllegalArgumentException("file should not be NULL");
        }
        file = raf;
    
Methods Summary
public voidclose()

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

        try {
            checkClosed();
            return file.length();
        } catch (IOException e) {
            return super.length(); // -1L
        }
    
public intread()

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

        checkClosed();
        int rt = file.read(b, off, len);
        if (rt != -1) {
            streamPos += rt;
        }
        return rt;
    
public voidseek(long pos)

        // -- checkClosed() is performed in super.seek()
        super.seek(pos);
        file.seek(pos);
        streamPos = file.getFilePointer();
    
public voidwrite(int b)

        checkClosed();
        // according to the spec for ImageOutputStreamImpl#flushBits()
        flushBits();
        file.write(b);
        streamPos++;
    
public voidwrite(byte[] b, int off, int len)

        checkClosed();
        // according to the spec for ImageOutputStreamImpl#flushBits()
        flushBits();
        file.write(b, off, len);
        streamPos += len;