public final class

SubImageInputStream

extends ImageInputStreamImpl
java.lang.Object
   ↳ javax.imageio.stream.ImageInputStreamImpl
     ↳ com.sun.imageio.plugins.common.SubImageInputStream

Summary

[Expand]
Inherited Fields
From class javax.imageio.stream.ImageInputStreamImpl
Public Constructors
SubImageInputStream(ImageInputStream stream, int length)
Public Methods
long length()
Returns -1L to indicate that the stream has unknown length.
int read()
Reads a single byte from the stream and returns it as an int between 0 and 255.
int read(byte[] b, int off, int len)
Reads up to len bytes from the stream, and stores them into b starting at index off.
void seek(long pos)
Sets the current stream position to the desired location.
Protected Methods
void finalize()
Finalizes this object prior to garbage collection.
[Expand]
Inherited Methods
From class javax.imageio.stream.ImageInputStreamImpl
From class java.lang.Object
From interface java.io.DataInput
From interface javax.imageio.stream.ImageInputStream

Public Constructors

public SubImageInputStream (ImageInputStream stream, int length)

Throws
IOException

Public Methods

public long length ()

Returns -1L to indicate that the stream has unknown length. Subclasses must override this method to provide actual length information.

Returns
  • -1L to indicate unknown length.

public int read ()

Reads a single byte from the stream and returns it as an int between 0 and 255. If EOF is reached, -1 is returned.

Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.

The bit offset within the stream must be reset to zero before the read occurs.

Returns
  • the value of the next byte in the stream, or -1 if EOF is reached.
Throws
IOException

public int read (byte[] b, int off, int len)

Reads up to len bytes from the stream, and stores them into b starting at index off. If no bytes can be read because the end of the stream has been reached, -1 is returned.

The bit offset within the stream must be reset to zero before the read occurs.

Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.

Parameters
b an array of bytes to be written to.
off the starting position within b to write to.
len the maximum number of bytes to read.
Returns
  • the number of bytes actually read, or -1 to indicate EOF.
Throws
IOException

public void seek (long pos)

Sets the current stream position to the desired location. The next read will occur at this location. The bit offset is set to 0.

An IndexOutOfBoundsException will be thrown if pos is smaller than the flushed position (as returned by getflushedPosition).

It is legal to seek past the end of the file; an EOFException will be thrown only if a read is performed.

Parameters
pos a long containing the desired file pointer position.
Throws
IOException

Protected Methods

protected void finalize ()

Finalizes this object prior to garbage collection. The close method is called to close any open input source. This method should not be called from application code.

Throws
Throwable