01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/TKByteArrayPrintStream.java,v 1.6 2001/06/11 14:04:38 alex Exp $
03: *
04: */
05: package com.teamkonzept.lib;
06:
07: import java.io.*;
08: import org.apache.log4j.Category;
09:
10: /**
11: *
12: */
13: public class TKByteArrayPrintStream extends PrintStream {
14: private static final Category cat = Category
15: .getInstance(TKByteArrayPrintStream.class);
16:
17: protected ByteArrayOutputStream buffer;
18: protected OutputStream outputStream;
19:
20: public TKByteArrayPrintStream(OutputStream outputStream) {
21: this (new ByteArrayOutputStream(), outputStream);
22: }
23:
24: protected TKByteArrayPrintStream(ByteArrayOutputStream buffer,
25: OutputStream outputStream) {
26: super (buffer);
27: this .buffer = buffer;
28: this .outputStream = outputStream;
29: }
30:
31: public ByteArrayOutputStream buffer() {
32: return buffer;
33: }
34:
35: public OutputStream outputStream() {
36: return outputStream;
37: }
38:
39: public void flush() {
40: try {
41: if (buffer.size() > 0) {
42: buffer.writeTo(outputStream);
43: buffer.reset();
44: }
45: } catch (IOException e) {
46: cat.error("message: ", e);
47: }
48: }
49: }
|