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.
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.
CachedStreamFactory
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
File |
getCacheDirectory()
Gets the cache directory where temporary cache files are created.
|
CachedInputStream |
getInputStream() |
long |
getMemCacheSize() |
CachedStreamFactory |
getStreamFactory() |
boolean |
isCacheEmpty()
Returns
true if was nothing to cache (no writing was
performed) or if the stream was closed. |
CachedOutputStream |
newOuputStream() |
CachedOutputStream |
newOuputStream(OutputStream os) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
flush, write
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public CachedInputStream getInputStream() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public final File getCacheDirectory()
getCacheDirectory
in interface ICachedStream
public CachedStreamFactory getStreamFactory()
public boolean isCacheEmpty()
true
if was nothing to cache (no writing was
performed) or if the stream was closed.true
if emptypublic CachedOutputStream newOuputStream(OutputStream os)
public CachedOutputStream newOuputStream()
public long getMemCacheSize()
getMemCacheSize
in interface ICachedStream
Copyright © 2008–2021 Norconex Inc.. All rights reserved.