1 package dolda.jsvc.util;
4 import java.nio.ByteBuffer;
5 import java.nio.CharBuffer;
6 import java.nio.charset.Charset;
7 import java.nio.charset.CharsetDecoder;
9 public class MixedBuffer {
10 private ByteArrayOutputStream buf = new ByteArrayOutputStream();
14 public MixedBuffer(Charset cs) {
16 conv = new OutputStreamWriter(buf, cs);
19 public MixedBuffer() {
23 public void append(byte b) {
27 public void append(char c) {
31 } catch(IOException e) {
36 public String convert() throws java.nio.charset.CharacterCodingException {
37 CharsetDecoder dec = cs.newDecoder();
38 ByteBuffer in = ByteBuffer.wrap(buf.toByteArray());
39 CharBuffer out = dec.decode(in);
40 return(out.toString());