Class OutputStreamCopier
- java.lang.Object
-
- java.io.OutputStream
-
- hu.icellmobilsoft.coffee.tool.utils.stream.OutputStreamCopier
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class OutputStreamCopier extends OutputStream
Copy original output stream to byte[] object. Usage:
// get the stream OutputStream originalStream = context.getOutputStream(); // create this stream copier object OutputStreamCopier osc = new OutputStreamCopier(originalStream); // set back this created stream context.setOutputStream(osc); // call stream consumer, example: try { context.proceed(); } finally { context.setOutputStream(originalStream); } // get the stream data copy and use to anything byte[] byteCopy = osc.getCopy();- Since:
- 1.0.0
- Author:
- imre.scheffer
-
-
Constructor Summary
Constructors Constructor Description OutputStreamCopier(OutputStream outputStream)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getCopy()Copy of used output stream data.voidwrite(int b)-
Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write, write
-
-
-
-
Constructor Detail
-
OutputStreamCopier
public OutputStreamCopier(OutputStream outputStream)
Constructor- Parameters:
outputStream- original outputStream what we want to copy
-
-
Method Detail
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
getCopy
public byte[] getCopy()
Copy of used output stream data.- Returns:
- byte array copy
-
-