Code example for Charset

Methods: newDecoder

0
    private java.nio.ByteBuffer buf = ByteBuffer.allocate(1024);
    private CharBuffer out = CharBuffer.allocate(1024);
 
    public WriterOutputStream(Writer out, Charset charset) {
        this.writer = out;
        decoder = charset.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.REPLACE);
        decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
    } 
 
    public WriterOutputStream(Writer out) {
        this(out,DEFAULT_CHARSET);
    } 
 
    public void write(int b) throws IOException {
        if(buf.remaining()==0)
            decode(false); 
        buf.put((byte)b);
    } 
 
    public void write(byte b[], int off, int len) throws IOException {