FileDocCategorySizeDatePackage
SubImageInputStream.javaAPI DocJava SE 6 API1615Tue Jun 10 00:21:52 BST 2008com.sun.imageio.plugins.common

SubImageInputStream

public final class SubImageInputStream extends ImageInputStreamImpl
version
0.5

Fields Summary
ImageInputStream
stream
long
startingPos
int
startingLength
int
length
Constructors Summary
public SubImageInputStream(ImageInputStream stream, int length)

        this.stream = stream;
        this.startingPos = stream.getStreamPosition();
        this.startingLength = this.length = length;
    
Methods Summary
protected voidfinalize()

        // Empty finalizer (for improved performance; no need to call
        // super.finalize() in this case)
    
public longlength()

        return startingLength;
    
public intread()

        if (length == 0) { // Local EOF
            return -1;
        } else {
            --length;
            return stream.read();
        }
    
public intread(byte[] b, int off, int len)

        if (length == 0) { // Local EOF
            return -1;
        }

        len = Math.min(len, length);
        int bytes = stream.read(b, off, len);
        length -= bytes;
        return bytes;
    
public voidseek(long pos)

        stream.seek(pos - startingPos);
        streamPos = pos;