1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.http.util;
14
15 import java.io.OutputStream;
16 import java.io.PrintWriter;
17 import java.io.UnsupportedEncodingException;
18 import java.nio.charset.IllegalCharsetNameException;
19
20 public class EncodingPrintWrtier extends PrintWriter {
21
22 protected BufferlessOutputStreamWriter cachedOut;
23
24 public EncodingPrintWrtier(OutputStream outputStream, String encoding) throws IllegalCharsetNameException, UnsupportedEncodingException {
25 super(new BufferlessOutputStreamWriter(outputStream, encoding));
26 cachedOut = (BufferlessOutputStreamWriter)out;
27 }
28
29 public void close() {
30 super.close();
31 }
32
33 public void resetInternals() {
34 out = cachedOut;
35 }
36
37 public void setEncoding(String encoding) throws UnsupportedEncodingException, IllegalCharsetNameException {
38 cachedOut.setEncoding(encoding);
39 }
40
41 public String getEcoding() {
42 return cachedOut.getEncoding();
43 }
44 }