Java Code Examples for com.sun.imageio.stream.StreamCloser#addToQueue()

The following examples show how to use com.sun.imageio.stream.StreamCloser#addToQueue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileCacheImageOutputStream.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 2
Source File: FileCacheImageOutputStream.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 3
Source File: FileCacheImageOutputStream.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 4
Source File: FileCacheImageOutputStream.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 5
Source File: FileCacheImageOutputStream.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 6
Source File: FileCacheImageOutputStream.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 7
Source File: FileCacheImageOutputStream.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 8
Source File: FileCacheImageOutputStream.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 9
Source File: FileCacheImageOutputStream.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 10
Source File: FileCacheImageOutputStream.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 11
Source File: FileCacheImageOutputStream.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 12
Source File: FileCacheImageOutputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 13
Source File: FileCacheImageOutputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 14
Source File: FileCacheImageOutputStream.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 15
Source File: FileCacheImageOutputStream.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 16
Source File: FileCacheImageOutputStream.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}
 
Example 17
Source File: FileCacheImageOutputStream.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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) {
        throw new IllegalArgumentException("stream == null!");
    }
    if ((cacheDir != null) && !(cacheDir.isDirectory())) {
        throw new IllegalArgumentException("Not a directory!");
    }
    this.stream = stream;
    if (cacheDir == null)
        this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
    else
        this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
                              .toFile();
    this.cache = new RandomAccessFile(cacheFile, "rw");

    this.closeAction = StreamCloser.createCloseAction(this);
    StreamCloser.addToQueue(closeAction);
}