< prev index next >
src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageOutputStream.java
Print this page
*** 27,41 ****
import java.io.IOException;
import java.io.OutputStream;
/**
! * An implementation of <code>ImageOutputStream</code> that writes its
! * output to a regular <code>OutputStream</code>. A memory buffer is
* used to cache at least the data between the discard position and
* the current write position. The only constructor takes an
! * <code>OutputStream</code>, so this class may not be used for
* read/modify/write operations. Reading can occur only on parts of
* the stream that have already been written to the cache and not
* yet flushed.
*
*/
--- 27,41 ----
import java.io.IOException;
import java.io.OutputStream;
/**
! * An implementation of {@code ImageOutputStream} that writes its
! * output to a regular {@code OutputStream}. A memory buffer is
* used to cache at least the data between the discard position and
* the current write position. The only constructor takes an
! * {@code OutputStream}, so this class may not be used for
* read/modify/write operations. Reading can occur only on parts of
* the stream that have already been written to the cache and not
* yet flushed.
*
*/
*** 44,60 ****
private OutputStream stream;
private MemoryCache cache = new MemoryCache();
/**
! * Constructs a <code>MemoryCacheImageOutputStream</code> that will write
! * to a given <code>OutputStream</code>.
*
! * @param stream an <code>OutputStream</code> to write to.
*
! * @exception IllegalArgumentException if <code>stream</code> is
! * <code>null</code>.
*/
public MemoryCacheImageOutputStream(OutputStream stream) {
if (stream == null) {
throw new IllegalArgumentException("stream == null!");
}
--- 44,60 ----
private OutputStream stream;
private MemoryCache cache = new MemoryCache();
/**
! * Constructs a {@code MemoryCacheImageOutputStream} that will write
! * to a given {@code OutputStream}.
*
! * @param stream an {@code OutputStream} to write to.
*
! * @exception IllegalArgumentException if {@code stream} is
! * {@code null}.
*/
public MemoryCacheImageOutputStream(OutputStream stream) {
if (stream == null) {
throw new IllegalArgumentException("stream == null!");
}
*** 127,179 ****
return -1L;
}
}
/**
! * 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>false</code> since this
! * <code>ImageOutputStream</code> does not maintain a file cache.
*
! * @return <code>false</code>.
*
* @see #isCached
* @see #isCachedMemory
*/
public boolean isCachedFile() {
return false;
}
/**
! * Returns <code>true</code> since this
! * <code>ImageOutputStream</code> maintains a main memory cache.
*
! * @return <code>true</code>.
*
* @see #isCached
* @see #isCachedFile
*/
public boolean isCachedMemory() {
return true;
}
/**
! * Closes this <code>MemoryCacheImageOutputStream</code>. All
* pending data is flushed to the output, and the cache
! * is released. The destination <code>OutputStream</code>
* is not closed.
*/
public void close() throws IOException {
long length = cache.getLength();
seek(length);
--- 127,179 ----
return -1L;
}
}
/**
! * 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 false} since this
! * {@code ImageOutputStream} does not maintain a file cache.
*
! * @return {@code false}.
*
* @see #isCached
* @see #isCachedMemory
*/
public boolean isCachedFile() {
return false;
}
/**
! * Returns {@code true} since this
! * {@code ImageOutputStream} maintains a main memory cache.
*
! * @return {@code true}.
*
* @see #isCached
* @see #isCachedFile
*/
public boolean isCachedMemory() {
return true;
}
/**
! * Closes this {@code MemoryCacheImageOutputStream}. All
* pending data is flushed to the output, and the cache
! * is released. The destination {@code OutputStream}
* is not closed.
*/
public void close() throws IOException {
long length = cache.getLength();
seek(length);
< prev index next >