Package 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:
Closeable,DataInput,DataOutput,AutoCloseable,ImageInputStream,ImageOutputStream
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:
-
Field Summary
Fields inherited from class javax.imageio.stream.ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos -
Constructor Summary
ConstructorsConstructorDescriptionFileChannelImageOutputStream(FileChannel channel) Constructs aFileChannelImageOutputStreamfrom aFileChannel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Invokes the superclass method, writes any unwritten data, and sets the internal reference to the sourceFileChanneltonull.longlength()Returns the number of bytes currently in theFileChannel.intread()intread(byte[] b, int off, int len) voidreadFully(char[] c, int off, int len) voidreadFully(double[] d, int off, int len) voidreadFully(float[] f, int off, int len) voidreadFully(int[] i, int off, int len) voidreadFully(long[] l, int off, int len) voidreadFully(short[] s, int off, int len) voidseek(long pos) Invokes the superclass method, writes any unwritten data, and sets the channel position to the supplied parameter.voidsetByteOrder(ByteOrder networkByteOrder) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwriteChars(char[] c, int off, int len) voidwriteDoubles(double[] d, int off, int len) voidwriteFloats(float[] f, int off, int len) voidwriteInts(int[] i, int off, int len) voidwriteLongs(long[] l, int off, int len) voidwriteShorts(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, writeUTFMethods 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, skipBytesMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, skipBytesMethods inherited from interface javax.imageio.stream.ImageOutputStream
flushBefore
-
Constructor Details
-
FileChannelImageOutputStream
Constructs aFileChannelImageOutputStreamfrom aFileChannel. The initial position of the stream stream is taken to be the position of theFileChannelparameter when this constructor is invoked. The stream and flushed positions are therefore both initialized tochannel.position().- Parameters:
channel- the destinationFileChannel.- Throws:
IllegalArgumentException- ifchannelisnullor is not open.IOException- if a method invoked onchannelthrows anIOException.
-
-
Method Details
-
read
- Specified by:
readin interfaceImageInputStream- Specified by:
readin classImageInputStreamImpl- Throws:
IOException
-
read
- Specified by:
readin interfaceImageInputStream- Specified by:
readin classImageInputStreamImpl- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceImageOutputStream- Specified by:
writein classImageOutputStreamImpl- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceImageOutputStream- Specified by:
writein classImageOutputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Overrides:
readFullyin classImageInputStreamImpl- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceImageOutputStream- Overrides:
writeCharsin classImageOutputStreamImpl- Throws:
IOException
-
writeShorts
- Specified by:
writeShortsin interfaceImageOutputStream- Overrides:
writeShortsin classImageOutputStreamImpl- Throws:
IOException
-
writeInts
- Specified by:
writeIntsin interfaceImageOutputStream- Overrides:
writeIntsin classImageOutputStreamImpl- Throws:
IOException
-
writeLongs
- Specified by:
writeLongsin interfaceImageOutputStream- Overrides:
writeLongsin classImageOutputStreamImpl- Throws:
IOException
-
writeFloats
- Specified by:
writeFloatsin interfaceImageOutputStream- Overrides:
writeFloatsin classImageOutputStreamImpl- Throws:
IOException
-
writeDoubles
- Specified by:
writeDoublesin interfaceImageOutputStream- Overrides:
writeDoublesin classImageOutputStreamImpl- Throws:
IOException
-
close
Invokes the superclass method, writes any unwritten data, and sets the internal reference to the sourceFileChanneltonull. The sourceFileChannelis not closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceImageInputStream- Overrides:
closein classImageInputStreamImpl- Throws:
IOException- if an error occurs.
-
length
public long length()Returns the number of bytes currently in theFileChannel. If anIOExceptionis encountered when querying the channel's size, -1L will be returned.- Specified by:
lengthin interfaceImageInputStream- Overrides:
lengthin classImageInputStreamImpl- Returns:
- The number of bytes in the channel -1L to indicate unknown length.
-
seek
Invokes the superclass method, writes any unwritten data, and sets the channel position to the supplied parameter.- Specified by:
seekin interfaceImageInputStream- Overrides:
seekin classImageInputStreamImpl- Throws:
IOException
-
setByteOrder
- Specified by:
setByteOrderin interfaceImageInputStream- Overrides:
setByteOrderin classImageInputStreamImpl
-