< prev index next >

src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java

Print this page

        

*** 31,42 **** import java.io.RandomAccessFile; import java.nio.file.Files; import com.sun.imageio.stream.StreamCloser; /** ! * An implementation of <code>ImageOutputStream</code> that writes its ! * output to a regular <code>OutputStream</code>. A file is used to * cache data until it is flushed to the output stream. * */ public class FileCacheImageOutputStream extends ImageOutputStreamImpl { --- 31,42 ---- import java.io.RandomAccessFile; import java.nio.file.Files; import com.sun.imageio.stream.StreamCloser; /** ! * An implementation of {@code ImageOutputStream} that writes its ! * output to a regular {@code OutputStream}. A file is used to * cache data until it is flushed to the output stream. * */ public class FileCacheImageOutputStream extends ImageOutputStreamImpl {
*** 52,80 **** /** The CloseAction that closes the stream in * the StreamCloser's shutdown hook */ private final StreamCloser.CloseAction closeAction; /** ! * Constructs a <code>FileCacheImageOutputStream</code> that will write ! * to a given <code>outputStream</code>. * * <p> A temporary file is used as a cache. If ! * <code>cacheDir</code>is non-<code>null</code> and is a * directory, the file will be created there. If it is ! * <code>null</code>, the system-dependent default temporary-file * directory will be used (see the documentation for ! * <code>File.createTempFile</code> for details). * ! * @param stream an <code>OutputStream</code> to write to. ! * @param cacheDir a <code>File</code> indicating where the ! * cache file should be created, or <code>null</code> to use the * system directory. * ! * @exception IllegalArgumentException if <code>stream</code> ! * is <code>null</code>. ! * @exception IllegalArgumentException if <code>cacheDir</code> is ! * non-<code>null</code> but is not a directory. * @exception IOException if a cache file cannot be created. */ public FileCacheImageOutputStream(OutputStream stream, File cacheDir) throws IOException { if (stream == null) { --- 52,80 ---- /** The CloseAction that closes the stream in * the StreamCloser's shutdown hook */ private final StreamCloser.CloseAction closeAction; /** ! * Constructs a {@code FileCacheImageOutputStream} that will write ! * to a given {@code outputStream}. * * <p> A temporary file is used as a cache. If ! * {@code cacheDir} is non-{@code null} and is a * directory, the file will be created there. If it is ! * {@code null}, the system-dependent default temporary-file * directory will be used (see the documentation for ! * {@code File.createTempFile} for details). * ! * @param stream an {@code OutputStream} to write to. ! * @param cacheDir a {@code File} indicating where the ! * cache file should be created, or {@code null} to use the * system directory. * ! * @exception IllegalArgumentException if {@code stream} ! * is {@code null}. ! * @exception IllegalArgumentException if {@code cacheDir} is ! * non-{@code null} but is not a directory. * @exception IOException if a cache file cannot be created. */ public FileCacheImageOutputStream(OutputStream stream, File cacheDir) throws IOException { if (stream == null) {
*** 153,167 **** } /** * Sets the current stream position and resets the bit offset to * 0. It is legal to seek past the end of the file; an ! * <code>EOFException</code> will be thrown only if a read is * performed. The file length will not be increased until a write * is performed. * ! * @exception IndexOutOfBoundsException if <code>pos</code> is smaller * than the flushed position. * @exception IOException if any other I/O error occurs. */ public void seek(long pos) throws IOException { checkClosed(); --- 153,167 ---- } /** * Sets the current stream position and resets the bit offset to * 0. It is legal to seek past the end of the file; an ! * {@code EOFException} will be thrown only if a read is * performed. The file length will not be increased until a write * is performed. * ! * @exception IndexOutOfBoundsException if {@code pos} is smaller * than the flushed position. * @exception IOException if any other I/O error occurs. */ public void seek(long pos) throws IOException { checkClosed();
*** 175,228 **** maxStreamPos = Math.max(maxStreamPos, streamPos); this.bitOffset = 0; } /** ! * Returns <code>true</code> since this ! * <code>ImageOutputStream</code> caches data in order to allow * seeking backwards. * ! * @return <code>true</code>. * * @see #isCachedMemory * @see #isCachedFile */ public boolean isCached() { return true; } /** ! * Returns <code>true</code> since this ! * <code>ImageOutputStream</code> maintains a file cache. * ! * @return <code>true</code>. * * @see #isCached * @see #isCachedMemory */ public boolean isCachedFile() { return true; } /** ! * Returns <code>false</code> since this ! * <code>ImageOutputStream</code> does not maintain a main memory * cache. * ! * @return <code>false</code>. * * @see #isCached * @see #isCachedFile */ public boolean isCachedMemory() { return false; } /** ! * Closes this <code>FileCacheImageOutputStream</code>. All * pending data is flushed to the output, and the cache file ! * is closed and removed. The destination <code>OutputStream</code> * is not closed. * * @exception IOException if an error occurs. */ public void close() throws IOException { --- 175,228 ---- maxStreamPos = Math.max(maxStreamPos, streamPos); this.bitOffset = 0; } /** ! * Returns {@code true} since this ! * {@code ImageOutputStream} caches data in order to allow * seeking backwards. * ! * @return {@code true}. * * @see #isCachedMemory * @see #isCachedFile */ public boolean isCached() { return true; } /** ! * Returns {@code true} since this ! * {@code ImageOutputStream} maintains a file cache. * ! * @return {@code true}. * * @see #isCached * @see #isCachedMemory */ public boolean isCachedFile() { return true; } /** ! * Returns {@code false} since this ! * {@code ImageOutputStream} does not maintain a main memory * cache. * ! * @return {@code false}. * * @see #isCached * @see #isCachedFile */ public boolean isCachedMemory() { return false; } /** ! * Closes this {@code FileCacheImageOutputStream}. All * pending data is flushed to the output, and the cache file ! * is closed and removed. The destination {@code OutputStream} * is not closed. * * @exception IOException if an error occurs. */ public void close() throws IOException {
< prev index next >