public class FileChannelImageInputStream
extends javax.imageio.stream.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.
ImageInputStream
,
java.nio
,
FileChannel
Constructor and Description |
---|
FileChannelImageInputStream(java.nio.channels.FileChannel channel)
Constructs a
FileChannelImageInputStream from a
FileChannel . |
Modifier and Type | Method and Description |
---|---|
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(double[] d,
int off,
int len) |
void |
readFully(float[] f,
int off,
int len) |
void |
readFully(int[] i,
int off,
int len) |
void |
readFully(long[] l,
int off,
int len) |
void |
readFully(short[] s,
int off,
int len) |
void |
seek(long pos)
Invokes the superclass method and sets the position within the
memory mapped buffer.
|
void |
setByteOrder(java.nio.ByteOrder networkByteOrder) |
checkClosed, finalize, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, setBitOffset, skipBytes, skipBytes
public FileChannelImageInputStream(java.nio.channels.FileChannel channel) throws java.io.IOException
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()
.channel
- the source FileChannel
.java.lang.IllegalArgumentException
- if channel
is
null
or is not open.java.io.IOException
- if a method invoked on channel
throws an IOException
.public int read() throws java.io.IOException
read
in interface javax.imageio.stream.ImageInputStream
read
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in interface javax.imageio.stream.ImageInputStream
read
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void close() throws java.io.IOException
FileChannel
to null
.
The source FileChannel
is not closed.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface javax.imageio.stream.ImageInputStream
close
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
- if an error occurs.public void readFully(char[] c, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void readFully(short[] s, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void readFully(int[] i, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void readFully(long[] l, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void readFully(float[] f, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void readFully(double[] d, int off, int len) throws java.io.IOException
readFully
in interface javax.imageio.stream.ImageInputStream
readFully
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public long length()
FileChannel
.
If an IOException
is encountered when querying the
channel's size, -1L will be returned.length
in interface javax.imageio.stream.ImageInputStream
length
in class javax.imageio.stream.ImageInputStreamImpl
public void seek(long pos) throws java.io.IOException
FileChannel
is not changed, i.e.,
FileChannel.position(long)
is not invoked.seek
in interface javax.imageio.stream.ImageInputStream
seek
in class javax.imageio.stream.ImageInputStreamImpl
java.io.IOException
public void setByteOrder(java.nio.ByteOrder networkByteOrder)
setByteOrder
in interface javax.imageio.stream.ImageInputStream
setByteOrder
in class javax.imageio.stream.ImageInputStreamImpl
Copyright © 2014 Open Microscopy Environment