Class CachedOutputStream

  • All Implemented Interfaces:
    ICachedStream, Closeable, Flushable, AutoCloseable

    public class CachedOutputStream
    extends OutputStream
    implements ICachedStream
    OutputStream wrapper that caches the output so it can be retrieved once as a CachedInputStream. Invoking getInputStream() effectively close() this stream and it can no longer be written to. Obtaining an input stream before or instead of calling the close method will not delete the cache content, but rather pass the reference to it to the CachedInputStream.

    To create new instances of CachedOutputStream, use the CachedStreamFactory class. Reusing the same factory will ensure all CachedOutputStream instances created share the same combined maximum memory. Invoking one of the newOutputStream(...) methods on this class have the same effect.

    The internal cache stores written bytes into memory, up to to the specified maximum cache size. If content exceeds the cache limit, the cache transforms itself into a file-based cache of unlimited size. Default memory cache size is 128 KB.

    Since:
    1.5
    Author:
    Pascal Essiembre
    See Also:
    CachedStreamFactory