Package sop.util
Class ProxyOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- sop.util.ProxyOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class ProxyOutputStream extends OutputStream
OutputStream
that buffers data being written into it, until its underlying output stream is being replaced. At that point, first all the buffered data is being written to the underlying stream, followed by any successive data that may get written to theProxyOutputStream
. This class is useful if we need to provide anOutputStream
at one point in time when the final target output stream is not yet known.
-
-
Constructor Summary
Constructors Constructor Description ProxyOutputStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
replaceOutputStream(OutputStream underlying)
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int i)
-
-
-
Constructor Detail
-
ProxyOutputStream
public ProxyOutputStream()
-
-
Method Detail
-
replaceOutputStream
public void replaceOutputStream(OutputStream underlying) throws IOException
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
write
public void write(int i) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
-