is there a way to buffer a OutputStream, modify it before it is returned? Here is my code snippet:
public ServletOutputStream getOutputStream() throws IOException {
BufferedOutputStream buffer = new BufferedOutputStream(super.getOutputStream());
// Modify the buffer contents, before it is returned
return new DelegatingServletOutputStream(buffer);
}
Thanks.
You can write your own FilterOutputStream:
This class is the superclass of all classes that filter output streams. These streams sit on top of an already existing output stream (the underlying output stream) which it uses as its basic sink of data, but possibly transforming the data along the way or providing additional functionality.