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