com.sun.media.imageio.stream

Class FileChannelImageOutputStream

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: javax.imageio.stream.ImageOutputStream java.nio java.nio.channels.FileChannel

Constructor Summary
FileChannelImageOutputStream(FileChannel channel)
Constructs a FileChannelImageOutputStream from a FileChannel.
Method Summary
voidclose()
Invokes the superclass method, writes any unwritten data, and sets the internal reference to the source FileChannel to null.
longlength()
Returns the number of bytes currently in the FileChannel.
intread()
intread(byte[] b, int off, int len)
voidreadFully(char[] c, int off, int len)
voidreadFully(short[] s, int off, int len)
voidreadFully(int[] i, int off, int len)
voidreadFully(long[] l, int off, int len)
voidreadFully(float[] f, int off, int len)
voidreadFully(double[] d, 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(int b)
voidwrite(byte[] b, int off, int len)
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)

Constructor Detail

FileChannelImageOutputStream

public FileChannelImageOutputStream(FileChannel channel)
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.

Method Detail

close

public void close()
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.

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.

Returns: The number of bytes in the channel -1L to indicate unknown length.

read

public int read()

read

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

readFully

public void readFully(char[] c, int off, int len)

readFully

public void readFully(short[] s, int off, int len)

readFully

public void readFully(int[] i, int off, int len)

readFully

public void readFully(long[] l, int off, int len)

readFully

public void readFully(float[] f, int off, int len)

readFully

public void readFully(double[] d, int off, int len)

seek

public void seek(long pos)
Invokes the superclass method, writes any unwritten data, and sets the channel position to the supplied parameter.

setByteOrder

public void setByteOrder(ByteOrder networkByteOrder)

write

public void write(int b)

write

public void write(byte[] b, int off, int len)

writeChars

public void writeChars(char[] c, int off, int len)

writeDoubles

public void writeDoubles(double[] d, int off, int len)

writeFloats

public void writeFloats(float[] f, int off, int len)

writeInts

public void writeInts(int[] i, int off, int len)

writeLongs

public void writeLongs(long[] l, int off, int len)

writeShorts

public void writeShorts(short[] s, int off, int len)