APIdia Launch Partner
Top Description Fields Constructors Methods
javax.imageio.stream

public Class FileImageOutputStream

extends ImageOutputStreamImpl
Class Inheritance
Imports
java.io.File, .FileNotFoundException, .IOException, .RandomAccessFile, com.sun.imageio.stream.CloseableDisposerRecord, sun.java2d.Disposer

An implementation of ImageOutputStream that writes its output directly to a File or RandomAccessFile.

Field Summary

Modifier and TypeField and Description
private final CloseableDisposerRecord
disposerRecord

The DisposerRecord that closes the underlying RandomAccessFile.

private final Object
disposerReferent

The referent to be registered with the Disposer.

private RandomAccessFile

Constructor Summary

AccessConstructor and Description
public
FileImageOutputStream(File
a File to write to.
f
)

Constructs a FileImageOutputStream that will write to a given File.

public
FileImageOutputStream(RandomAccessFile
a RandomAccessFile to write to.
raf
)

Constructs a FileImageOutputStream that will write to a given RandomAccessFile.

Method Summary

Modifier and TypeMethod and Description
public void
public long
length()

Overrides javax.imageio.stream.ImageInputStreamImpl.length.

Implements javax.imageio.stream.ImageInputStream.length.

Returns the total length of the stream, if known.

public int
read()

Implements abstract javax.imageio.stream.ImageInputStreamImpl.read.

Implements javax.imageio.stream.ImageInputStream.read.

Reads a single byte from the stream and returns it as an integer between 0 and 255.

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

Implements abstract javax.imageio.stream.ImageInputStreamImpl.read.

Implements javax.imageio.stream.ImageInputStream.read.

Reads up to len bytes from the stream, and stores them into b starting at index off.

public void
seek(long pos)

Overrides javax.imageio.stream.ImageInputStreamImpl.seek.

Implements javax.imageio.stream.ImageInputStream.seek.

Sets the current stream position and resets the bit offset to 0.

public void
write(int b)

Implements abstract javax.imageio.stream.ImageOutputStreamImpl.write.

Implements javax.imageio.stream.ImageOutputStream.write.

Writes a single byte to the stream at the current position.

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

Implements abstract javax.imageio.stream.ImageOutputStreamImpl.write.

Implements javax.imageio.stream.ImageOutputStream.write.

Writes a sequence of bytes to the stream at the current position.

Inherited from javax.imageio.stream.ImageOutputStreamImpl:
flushBitswritewriteBitwriteBitswriteBooleanwriteBytewriteByteswriteCharwriteCharswriteCharswriteDoublewriteDoubleswriteFloatwriteFloatswriteIntwriteIntswriteLongwriteLongswriteShortwriteShortswriteUTF

Field Detail

disposerRecordback to summary
private final CloseableDisposerRecord disposerRecord

The DisposerRecord that closes the underlying RandomAccessFile.

disposerReferentback to summary
private final Object disposerReferent

The referent to be registered with the Disposer.

rafback to summary
private RandomAccessFile raf

Constructor Detail

FileImageOutputStreamback to summary
public FileImageOutputStream(File f) throws FileNotFoundException, IOException

Constructs a FileImageOutputStream that will write to a given File.

Parameters
f:File

a File to write to.

Exceptions
FileNotFoundException:
if f does not denote a regular file or it cannot be opened for reading and writing for any other reason.
IOException:
if an I/O error occurs.
IllegalArgumentException:
if f is null.
FileImageOutputStreamback to summary
public FileImageOutputStream(RandomAccessFile raf)

Constructs a FileImageOutputStream that will write to a given RandomAccessFile.

Parameters
raf:RandomAccessFile

a RandomAccessFile to write to.

Exceptions
IllegalArgumentException:
if raf is null.

Method Detail

closeback to summary
public void close() throws IOException

Overrides javax.imageio.stream.ImageInputStreamImpl.close.

Implements javax.imageio.stream.ImageInputStream.close.

Doc from javax.imageio.stream.ImageInputStream.close.

Closes the stream. Attempts to access a stream that has been closed may result in IOExceptions or incorrect behavior. Calling this method may allow classes implementing this interface to release resources associated with the stream such as memory, disk space, or file descriptors.

Exceptions
IOException:
if an I/O error occurs.
lengthback to summary
public long length()

Overrides javax.imageio.stream.ImageInputStreamImpl.length.

Implements javax.imageio.stream.ImageInputStream.length.

Doc from javax.imageio.stream.ImageInputStream.length.

Returns the total length of the stream, if known. Otherwise, -1 is returned.

readback to summary
public int read() throws IOException

Implements abstract javax.imageio.stream.ImageInputStreamImpl.read.

Implements javax.imageio.stream.ImageInputStream.read.

Doc from javax.imageio.stream.ImageInputStream.read.

Reads a single byte from the stream and returns it as an integer between 0 and 255. If the end of the stream is reached, -1 is returned.

The bit offset within the stream is reset to zero before the read occurs.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Implements abstract javax.imageio.stream.ImageInputStreamImpl.read.

Implements javax.imageio.stream.ImageInputStream.read.

Doc from javax.imageio.stream.ImageInputStream.read.

Reads up to len bytes from the stream, and stores them into b starting at index off. The number of bytes read is returned. If no bytes can be read because the end of the stream has been reached, -1 is returned.

The bit offset within the stream is reset to zero before the read occurs.

Exceptions
IOException:
if an I/O error occurs.
seekback to summary
public void seek(long pos) throws IOException

Overrides javax.imageio.stream.ImageInputStreamImpl.seek.

Implements javax.imageio.stream.ImageInputStream.seek.

Sets the current stream position and resets the bit offset to 0. It is legal to seeking past the end of the file; an EOFException will be thrown only if a read is performed. The file length will not be increased until a write is performed.

Exceptions
IOException:
if any other I/O error occurs.
IndexOutOfBoundsException:
if pos is smaller than the flushed position.
writeback to summary
public void write(int b) throws IOException

Implements abstract javax.imageio.stream.ImageOutputStreamImpl.write.

Implements javax.imageio.stream.ImageOutputStream.write.

Doc from javax.imageio.stream.ImageOutputStream.write.

Writes a single byte to the stream at the current position. The 24 high-order bits of b are ignored.

If the bit offset within the stream is non-zero, the remainder of the current byte is padded with 0s and written out first. The bit offset will be 0 after the write. Implementers can use the flushBits method of ImageOutputStreamImpl to guarantee this.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Implements abstract javax.imageio.stream.ImageOutputStreamImpl.write.

Implements javax.imageio.stream.ImageOutputStream.write.

Doc from javax.imageio.stream.ImageOutputStream.write.

Writes a sequence of bytes to the stream at the current position. If len is 0, nothing is written. The byte b[off] is written first, then the byte b[off + 1], and so on.

If the bit offset within the stream is non-zero, the remainder of the current byte is padded with 0s and written out first. The bit offset will be 0 after the write. Implementers can use the flushBits method of ImageOutputStreamImpl to guarantee this.

Exceptions
IOException:
if an I/O error occurs.