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

MemoryCacheImageOutputStream

public class MemoryCacheImageOutputStream extends ImageOutputStreamImpl
The MemoryCacheImageOutputStream class implements ImageOutputStream using a memory buffer for caching the data.
since
Android 1.0

Fields Summary
OutputStream
os
The os.
org.apache.harmony.x.imageio.stream.RandomAccessMemoryCache
ramc
The ramc.
Constructors Summary
public MemoryCacheImageOutputStream(OutputStream stream)
Instantiates a new MemoryCacheImageOutputStream which writes to the specified OutputStream.

param
stream the OutputStream.


                                   
       
        if (stream == null) {
            throw new IllegalArgumentException("stream == null!");
        }
        os = stream;
    
Methods Summary
public voidclose()

        flushBefore(length());
        super.close();
        ramc.close();
    
public voidflushBefore(long pos)

        long flushedPosition = getFlushedPosition();
        super.flushBefore(pos);

        long newFlushedPosition = getFlushedPosition();
        int nBytes = (int)(newFlushedPosition - flushedPosition);

        ramc.getData(os, nBytes, flushedPosition);
        ramc.freeBefore(newFlushedPosition);

        os.flush();
    
public booleanisCached()

        return true;
    
public booleanisCachedFile()

        return false;
    
public booleanisCachedMemory()

        return true;
    
public longlength()

        return ramc.length();
    
public intread()

        bitOffset = 0;

        int res = ramc.getData(streamPos);
        if (res >= 0) {
            streamPos++;
        }
        return res;
    
public intread(byte[] b, int off, int len)

        bitOffset = 0;

        int res = ramc.getData(b, off, len, streamPos);
        if (res > 0) {
            streamPos += res;
        }
        return res;
    
public voidwrite(int b)

        flushBits(); // See the flushBits method description

        ramc.putData(b, streamPos);
        streamPos++;
    
public voidwrite(byte[] b, int off, int len)

        flushBits(); // See the flushBits method description

        ramc.putData(b, off, len, streamPos);
        streamPos += len;