Class MemoryCacheImageOutputStream
- java.lang.Object
-
- javax.imageio.stream.ImageInputStreamImpl
-
- javax.imageio.stream.ImageOutputStreamImpl
-
- javax.imageio.stream.MemoryCacheImageOutputStream
- All Implemented Interfaces:
-
Closeable,DataInput,DataOutput,AutoCloseable,ImageInputStream,ImageOutputStream
public class MemoryCacheImageOutputStream extends ImageOutputStreamImpl
An implementation of ImageOutputStream that writes its output to a regular 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 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.
Field Summary
Fields declared in class javax.imageio.stream.ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos Constructor Summary
| Constructor | Description |
|---|---|
MemoryCacheImageOutputStream(OutputStream stream) | Constructs a |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void | close() | Closes this |
boolean | isCached() | Returns |
boolean | isCachedFile() | Returns |
boolean | isCachedMemory() | Returns |
Methods declared in class javax.imageio.stream.ImageOutputStreamImpl
flushBits Methods declared in class javax.imageio.stream.ImageInputStreamImpl
checkClosed, finalize, length, mark, read, read, read, reset, skipBytes, skipBytes Methods declared in class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Methods declared in interface javax.imageio.stream.ImageInputStream
flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, length, mark, read, read, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytes Methods declared in interface javax.imageio.stream.ImageOutputStream
flushBefore, write, write, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTF Constructor Detail
MemoryCacheImageOutputStream
public MemoryCacheImageOutputStream(OutputStream stream)
Constructs a MemoryCacheImageOutputStream that will write to a given OutputStream.
- Parameters:
-
stream- anOutputStreamto write to. - Throws:
-
IllegalArgumentException- ifstreamisnull.
Method Detail
isCached
public boolean isCached()
Returns true since this ImageOutputStream caches data in order to allow seeking backwards.
- Specified by:
-
isCachedin interfaceImageInputStream - Overrides:
-
isCachedin classImageInputStreamImpl - Returns:
-
true. - See Also:
-
isCachedMemory(),isCachedFile()
isCachedFile
public boolean isCachedFile()
Returns false since this ImageOutputStream does not maintain a file cache.
- Specified by:
-
isCachedFilein interfaceImageInputStream - Overrides:
-
isCachedFilein classImageInputStreamImpl - Returns:
-
false. - See Also:
-
isCached(),isCachedMemory()
isCachedMemory
public boolean isCachedMemory()
Returns true since this ImageOutputStream maintains a main memory cache.
- Specified by:
-
isCachedMemoryin interfaceImageInputStream - Overrides:
-
isCachedMemoryin classImageInputStreamImpl - Returns:
-
true. - See Also:
-
isCached(),isCachedFile()
close
public void close()
throws IOException Closes this MemoryCacheImageOutputStream. All pending data is flushed to the output, and the cache is released. The destination OutputStream is not closed.
- Throws:
-
IOException- if an I/O error occurs.