1 package org.collectionspace.services.common.profile;
\r
4 import javax.servlet.*;
\r
6 public class BufferedServletOutputStream extends ServletOutputStream {
\r
8 private ByteArrayOutputStream bos = new ByteArrayOutputStream( );
\r
10 public String getAsString(){
\r
11 byte[] buf = bos.toByteArray();
\r
12 return new String(buf);
\r
16 * @return the contents of the buffer.
\r
18 public byte[] getBuffer( ) {
\r
19 return this.bos.toByteArray( );
\r
23 * This method must be defined for custom servlet output streams.
\r
25 public void write(int data) {
\r
26 this.bos.write(data);
\r
29 // BufferedHttpResponseWrapper calls this method
\r
30 public void reset( ) {
\r
34 // BufferedHttpResponseWrapper calls this method
\r
35 public void setBufferSize(int size) {
\r
36 // no way to resize an existing ByteArrayOutputStream
\r
37 this.bos = new ByteArrayOutputStream(size);
\r