]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
9279de39e1ef9538a43db793b57c35aab2ab1d09
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.common.profile;
2
3 import java.io.*;
4 import javax.servlet.*;
5
6 public class BufferedServletOutputStream extends ServletOutputStream {
7     // the actual buffer
8     private ByteArrayOutputStream bos = new ByteArrayOutputStream( );
9
10     public String getAsString(){
11         byte[] buf = bos.toByteArray();
12         return new String(buf);
13     }
14
15     /**
16      * @return the contents of the buffer.
17      */
18     public byte[] getBuffer( ) {
19         return this.bos.toByteArray( );
20     }
21
22     /**
23      * This method must be defined for custom servlet output streams.
24      */
25     public void write(int data) {
26         this.bos.write(data);
27     }
28
29     // BufferedHttpResponseWrapper calls this method
30     public void reset( ) {
31         this.bos.reset( );
32     }
33
34     // BufferedHttpResponseWrapper calls this method
35     public void setBufferSize(int size) {
36         // no way to resize an existing ByteArrayOutputStream
37         this.bos = new ByteArrayOutputStream(size);
38     }
39 }