com.sun.media.imageio.stream
public class FileChannelImageInputStream extends ImageInputStreamImpl
ImageInputStream
using a
FileChannel
as the eventual data source. The channel
contents are assumed to be stable during the lifetime of the object.
Memory mapping and new I/O view Buffer
s are used to
read the data. Only methods which provide significant performance
improvement with respect to the superclass implementation are overridden.
Overridden methods are not commented individually unless some noteworthy
aspect of the implementation must be described.
The methods of this class are not synchronized.
See Also: javax.imageio.stream.ImageInputStream java.nio java.nio.channels.FileChannel
Constructor Summary | |
---|---|
FileChannelImageInputStream(FileChannel channel)
Constructs a FileChannelImageInputStream from a
FileChannel . |
Method Summary | |
---|---|
void | close()
Invokes the superclass method and sets the internal reference
to the source FileChannel to null .
|
long | length()
Returns the number of bytes currently in the FileChannel .
|
int | read() |
int | read(byte[] b, int off, int len) |
void | readFully(char[] c, int off, int len) |
void | readFully(short[] s, int off, int len) |
void | readFully(int[] i, int off, int len) |
void | readFully(long[] l, int off, int len) |
void | readFully(float[] f, int off, int len) |
void | readFully(double[] d, int off, int len) |
void | seek(long pos)
Invokes the superclass method and sets the position within the
memory mapped buffer. |
void | setByteOrder(ByteOrder networkByteOrder) |
FileChannelImageInputStream
from a
FileChannel
. The initial position of the stream
stream is taken to be the position of the FileChannel
parameter when this constructor is invoked. The stream and flushed
positions are therefore both initialized to
channel.position()
.
Parameters: channel the source FileChannel
.
Throws: IllegalArgumentException if channel
is
null
or is not open. IOException if a method invoked on channel
throws an IOException
.
FileChannel
to null
.
The source FileChannel
is not closed.
Throws: IOException if an error occurs.
FileChannel
.
If an IOException
is encountered when querying the
channel's size, -1L will be returned.
Returns: The number of bytes in the channel -1L to indicate unknown length.
FileChannel
is not changed, i.e.,
java.nio.channels.FileChannel#position(long) is not invoked.