
net.sf.gluebooster.java.booster.basic.io.StoringOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gb-basic Show documentation
Show all versions of gb-basic Show documentation
Basic classes to support the development of applications. There should be as few dependencies on other frameworks as possible.
The newest version!
package net.sf.gluebooster.java.booster.basic.io;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* The external input is stored for repeated access.
* @author CBauer
*
*/
public class StoringOutputStream extends OutputStream{
/**
* The output stream to which the data is written.
*/
private OutputStream output;
/**
* Storage of the written output.
*/
private ByteArrayOutputStream storage = new ByteArrayOutputStream();
public StoringOutputStream(OutputStream output) {
this.output = output;
}
@Override
public void write(int b) throws IOException {
if (b != -1)
storage.write(b);
output.write(b);
}
public byte[] getStorage(){
return storage.toByteArray();
}
/**
* Gets the stored output as string.
*
* @return the converted storage
*/
public String getStorageString(){
return storage.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy