Spec-Zone.ru › OpenJDK 27

Package javax.imageio.stream

package javax.imageio.stream
A package of the Java Image I/O API dealing with low-level I/O from files and streams.

The ImageInputStream interface unifies streaming and file-based operations. An abstract base class, ImageInputStreamImpl is provided to simplify writing a new ImageInputStream class. Concrete implementation classes (FileImageInputStream, FileCacheImageInputStream, and MemoryCacheImageInputStream) are provided that allow input to come from a File or InputStream with or without the use of a temporary cache file.

The ImageOutputStream interface performs an analogous function for output. An abstract base class, ImageOutputStreamImpl is provided, along with concrete implementation classes (FileImageOutputStream, FileCacheImageOutputStream, and MemoryCacheImageOutputStream) are provided that allow output to go to a File or OutputStream with or without the use of a temporary cache file.

The IIOByteBuffer class provides an alternative way to perform reads of sequences of bytes that reduces the amount of internal data copying.

An ImageInputStream or ImageOutputStream may internally allocate system resources, such as a temporary cache file. Clients are encouraged to use a try-with-resources statement to ensure the ImageInputStream.close() or ImageInputStream.close() method is called which can promptly free those native resources. Otherwise there is the possibility they will leak and eventually cause the application to fail as well the possibility that not all data is flushed to the underlying output stream. A logical consequence of that is that this should be done before closing the destination OutputStream. A simple pattern would be

try (FileOutputStream fos = new FileOutputStream("out.jpg");
     ImageOutputStream ios = new FileCacheImageOutputStream(fos, null)) {
    ImageIO.write(img, "jpg", ios);
} catch (IOException e) {
} // implicit finally block closes the streams in the reverse order to opening

Sub-classers of these Image I/O API stream types can, to a limited extent, protect the application from the consequences of failures to close by adopting mechanisms such as Cleaner to free internal resources when it is no longer reachable. This is only necessary if there are any resources to release. However applications cannot rely on this, either for resource management, or for program correctness.

Since:
1.4
Package Description
javax.imageio
The main package of the Java Image I/O API.
javax.imageio.event
A package of the Java Image I/O API dealing with synchronous notification of events during the reading and writing of images.
javax.imageio.metadata
A package of the Java Image I/O API dealing with reading and writing metadata.
javax.imageio.spi
A package of the Java Image I/O API containing the plug-in interfaces for readers, writers, transcoders, and streams, and a runtime registry.
Class Description
FileCacheImageInputStream
An implementation of ImageInputStream that gets its input from a regular InputStream.
FileCacheImageOutputStream
An implementation of ImageOutputStream that writes its output to a regular OutputStream.
FileImageInputStream
An implementation of ImageInputStream that gets its input from a File or RandomAccessFile.
FileImageOutputStream
An implementation of ImageOutputStream that writes its output directly to a File or RandomAccessFile.
IIOByteBuffer
A class representing a mutable reference to an array of bytes and an offset and length within that array.
ImageInputStream
A seekable input stream interface for use by ImageReaders.
ImageInputStreamImpl
An abstract class implementing the ImageInputStream interface.
ImageOutputStream
A seekable output stream interface for use by ImageWriters.
ImageOutputStreamImpl
An abstract class implementing the ImageOutputStream interface.
MemoryCacheImageInputStream
An implementation of ImageInputStream that gets its input from a regular InputStream.
MemoryCacheImageOutputStream
An implementation of ImageOutputStream that writes its output to a regular OutputStream.

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API