1 4 package com.openedit.servlet; 5 6 import java.io.IOException ; 7 import java.io.OutputStream ; 8 import java.io.PrintWriter ; 9 10 import javax.servlet.ServletOutputStream ; 11 12 public class DecoratedServletOutputStream extends ServletOutputStream  13 { 14 PrintWriter writer; 15 OutputStream out; 16 public DecoratedServletOutputStream(PrintWriter inWriter) 17 { 18 this.writer = inWriter; 19 } 20 public DecoratedServletOutputStream(OutputStream inOut) 21 { 22 out = inOut; 23 } 24 public void write(int b) throws java.io.IOException  25 { 26 if ( writer != null ) 28 { 29 this.writer.write(b); 30 } 31 else 32 { 33 out.write(b); 34 } 35 } 36 public void write(byte[] inB) throws IOException  37 { 38 out.write(inB); 39 } 40 public void write(byte[] inB, int inOff, int inLen) throws IOException  41 { 42 out.write(inB,inOff,inLen); 44 } 45 public void flush() throws IOException  46 { 47 if( writer != null) 48 { 49 writer.flush(); 50 } 51 else 52 { 53 out.flush(); 54 } 55 } 56 57 public PrintWriter getWriter() 58 { 59 return writer; 60 } 61 62 } 63 | Popular Tags |