01: package pygmy.core;
02:
03: import java.io.PrintWriter;
04: import java.io.StringWriter;
05: import java.io.OutputStream;
06: import java.io.IOException;
07:
08: public class PrintWriterResponseData implements ResponseData {
09: PrintWriter writer;
10: StringWriter backEnd;
11:
12: public PrintWriterResponseData() {
13: backEnd = new StringWriter();
14: writer = new PrintWriter(backEnd);
15: }
16:
17: public long getLength() {
18: writer.flush();
19: return backEnd.getBuffer().length();
20: }
21:
22: public PrintWriter getPrintWriter() {
23: return writer;
24: }
25:
26: public void send(OutputStream os) throws IOException {
27: writer.flush();
28: os.write(backEnd.toString().getBytes());
29: }
30: }
|