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
OutputStreamthat 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 anOutputStreamat 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 voidclose()voidflush()voidreplaceOutputStream(OutputStream underlying)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(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:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
write
public void write(int i) throws IOException
- Specified by:
writein classOutputStream- Throws:
IOException
-
-