saveStream public class SaveStream { private InputStream input; private byte[] data = new byte[0]; public SaveStream(InputStream input) throws IOException { this.input = input; save(); } private void save() throws IOException { ByteArrayOut
public class SaveStream { private InputStream input; private byte[] data = new byte[0]; public SaveStream(InputStream input) throws IOException { this.input = input; save(); } private void save() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = -1; while ((len = input.read(buffer)) != -1) { output.write(buffer, 0, len); } data = output.toByteArray(); } public InputStream getInputStream() { return new ByteArrayInputStream(data); } }