com.sun.media.imageio.stream
Class FileChannelImageOutputStream
java.lang.Object
|
+--javax.imageio.stream.ImageInputStreamImpl
|
+--javax.imageio.stream.ImageOutputStreamImpl
|
+--com.sun.media.imageio.stream.FileChannelImageOutputStream
- All Implemented Interfaces:
- DataInput, DataOutput, ImageInputStream, ImageOutputStream
- public class FileChannelImageOutputStream
- extends ImageOutputStreamImpl
A class which implements ImageOutputStream
using a
FileChannel
as the eventual data destination.
Memory mapping is used for reading and direct buffers for writing.
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:
ImageOutputStream
,
java.nio,
FileChannel
Method Summary |
void |
close()
Invokes the superclass method, writes any unwritten data, 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, writes any unwritten data,
and sets the channel position to the supplied parameter. |
void |
setByteOrder(ByteOrder networkByteOrder)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeChars(char[] c,
int off,
int len)
|
void |
writeDoubles(double[] d,
int off,
int len)
|
void |
writeFloats(float[] f,
int off,
int len)
|
void |
writeInts(int[] i,
int off,
int len)
|
void |
writeLongs(long[] l,
int off,
int len)
|
void |
writeShorts(short[] s,
int off,
int len)
|
Methods inherited from class javax.imageio.stream.ImageOutputStreamImpl |
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
Methods inherited from class javax.imageio.stream.ImageInputStreamImpl |
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 |
Methods inherited from interface javax.imageio.stream.ImageInputStream |
flush, 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 |
FileChannelImageOutputStream
public FileChannelImageOutputStream(FileChannel channel)
throws IOException
- Constructs a
FileChannelImageOutputStream
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 destination FileChannel
.
- Throws:
IllegalArgumentException
- if channel
is
null
or is not open.
IOException
- if a method invoked on channel
throws an IOException
.
read
public int read()
throws IOException
- Specified by:
read
in interface ImageInputStream
- Specified by:
read
in class ImageInputStreamImpl
IOException
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Specified by:
read
in interface ImageInputStream
- Specified by:
read
in class ImageInputStreamImpl
IOException
write
public void write(int b)
throws IOException
- Specified by:
write
in interface ImageOutputStream
- Specified by:
write
in class ImageOutputStreamImpl
IOException
write
public void write(byte[] b,
int off,
int len)
throws IOException
- Specified by:
write
in interface ImageOutputStream
- Specified by:
write
in class ImageOutputStreamImpl
IOException
readFully
public void readFully(char[] c,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
readFully
public void readFully(short[] s,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
readFully
public void readFully(int[] i,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
readFully
public void readFully(long[] l,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
readFully
public void readFully(float[] f,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
readFully
public void readFully(double[] d,
int off,
int len)
throws IOException
- Specified by:
readFully
in interface ImageInputStream
- Overrides:
readFully
in class ImageInputStreamImpl
IOException
writeChars
public void writeChars(char[] c,
int off,
int len)
throws IOException
- Specified by:
writeChars
in interface ImageOutputStream
- Overrides:
writeChars
in class ImageOutputStreamImpl
IOException
writeShorts
public void writeShorts(short[] s,
int off,
int len)
throws IOException
- Specified by:
writeShorts
in interface ImageOutputStream
- Overrides:
writeShorts
in class ImageOutputStreamImpl
IOException
writeInts
public void writeInts(int[] i,
int off,
int len)
throws IOException
- Specified by:
writeInts
in interface ImageOutputStream
- Overrides:
writeInts
in class ImageOutputStreamImpl
IOException
writeLongs
public void writeLongs(long[] l,
int off,
int len)
throws IOException
- Specified by:
writeLongs
in interface ImageOutputStream
- Overrides:
writeLongs
in class ImageOutputStreamImpl
IOException
writeFloats
public void writeFloats(float[] f,
int off,
int len)
throws IOException
- Specified by:
writeFloats
in interface ImageOutputStream
- Overrides:
writeFloats
in class ImageOutputStreamImpl
IOException
writeDoubles
public void writeDoubles(double[] d,
int off,
int len)
throws IOException
- Specified by:
writeDoubles
in interface ImageOutputStream
- Overrides:
writeDoubles
in class ImageOutputStreamImpl
IOException
close
public void close()
throws IOException
- Invokes the superclass method, writes any unwritten data, and
sets the internal reference to the source
FileChannel
to null
. The source FileChannel
is not
closed.
- Specified by:
close
in interface ImageInputStream
- Overrides:
close
in class ImageInputStreamImpl
- Throws:
IOException
- if an error occurs.
length
public long length()
- Returns the number of bytes currently in the
FileChannel
.
If an IOException
is encountered when querying the
channel's size, -1L will be returned.
- Specified by:
length
in interface ImageInputStream
- Overrides:
length
in class ImageInputStreamImpl
- Returns:
- The number of bytes in the channel
-1L to indicate unknown length.
seek
public void seek(long pos)
throws IOException
- Invokes the superclass method, writes any unwritten data,
and sets the channel position to the supplied parameter.
- Specified by:
seek
in interface ImageInputStream
- Overrides:
seek
in class ImageInputStreamImpl
IOException
setByteOrder
public void setByteOrder(ByteOrder networkByteOrder)
- Specified by:
setByteOrder
in interface ImageInputStream
- Overrides:
setByteOrder
in class ImageInputStreamImpl