Package org.teavm.classlib.impl.charset

Examples of org.teavm.classlib.impl.charset.CharBuffer


        return fillBuffer() ? outBuffer.get() : -1;
    }

    @Override
    public int read(char[] cbuf, int off, int len) throws TIOException {
        CharBuffer wrapBuffer = new CharBuffer(cbuf, off, off + len);
        while (!wrapBuffer.end()) {
            wrapBuffer.put(outBuffer);
            if (outBuffer.end() && !fillBuffer()) {
                break;
            }
        }
        return wrapBuffer.position() - off;
    }
View Full Code Here


    private boolean fillBuffer() throws TIOException {
        if (eof) {
            return false;
        }
        CharBuffer newBuffer = new CharBuffer(outData);
        newBuffer.put(outBuffer);
        while (true) {
            if (inBuffer.end() && !fillReadBuffer()) {
                eof = true;
                break;
            }
            int oldAvail = newBuffer.available();
            charset.decode(inBuffer, newBuffer);
            if (oldAvail == newBuffer.available()) {
                break;
            }
        }
        outBuffer = new CharBuffer(outData, 0, newBuffer.position());
        return true;
    }
View Full Code Here

    public void print(char[] s) {
        print(s, 0, s.length);
    }

    private void print(char[] s, int begin, int end) {
        CharBuffer src = new CharBuffer(s, begin, end);
        byte[] destBytes = new byte[TMath.max(16, TMath.min(s.length, 1024))];
        ByteBuffer dest = new ByteBuffer(destBytes);
        while (!src.end()) {
            charset.encode(src, dest);
            write(destBytes, 0, dest.position());
            dest.rewind(0);
        }
    }
View Full Code Here

TOP

Related Classes of org.teavm.classlib.impl.charset.CharBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.