1 package org.roller.presentation.filters; 2 3 import java.io.PrintWriter ; 4 import java.io.OutputStreamWriter ; 5 import java.io.ByteArrayOutputStream ; 6 7 import javax.servlet.ServletOutputStream ; 8 import javax.servlet.ServletResponse ; 9 import javax.servlet.http.HttpServletResponse ; 10 import javax.servlet.http.HttpServletResponseWrapper ; 11 12 17 public class ByteArrayResponseWrapper extends HttpServletResponseWrapper 18 { 19 private PrintWriter tpWriter; 20 private ByteArrayOutputStreamWrapper tpStream; 21 22 public ByteArrayResponseWrapper(ServletResponse inResp) 23 throws java.io.IOException 24 { 25 super((HttpServletResponse ) inResp); 26 tpStream = new ByteArrayOutputStreamWrapper(inResp.getOutputStream()); 27 tpWriter = new PrintWriter (new OutputStreamWriter (tpStream,"UTF-8")); 28 } 29 30 public ServletOutputStream getOutputStream() 31 throws java.io.IOException 32 { 33 return tpStream; 34 } 35 36 public PrintWriter getWriter() throws java.io.IOException 37 { 38 return tpWriter; 39 } 40 41 43 public String toString() 44 { 45 return tpStream.getByteArrayStream().toString(); 46 } 47 48 public ByteArrayOutputStream getByteArrayOutputStream() 49 throws java.io.IOException 50 { 51 return tpStream.getByteArrayStream(); 52 } 53 } 54 | Popular Tags |