Package org.teavm.classlib.java.io

Examples of org.teavm.classlib.java.io.TByteArrayOutputStream


     * @return java.lang.String The decoded version.
     */
    static TString decode(TString s) {

        TStringBuilder result = new TStringBuilder();
        TByteArrayOutputStream out = new TByteArrayOutputStream();
        for (int i = 0; i < s.length();) {
            char c = s.charAt(i);
            if (c == '%') {
                out.reset();
                do {
                    if (i + 2 >= s.length()) {
                        throw new TIllegalArgumentException();
                    }
                    int d1 = TCharacter.digit(s.charAt(i + 1), 16);
                    int d2 = TCharacter.digit(s.charAt(i + 2), 16);
                    if (d1 == -1 || d2 == -1) {
                        throw new TIllegalArgumentException();
                    }
                    out.write((byte) ((d1 << 4) + d2));
                    i += 3;
                } while (i < s.length() && s.charAt(i) == '%');
                result.append(TString.wrap(out.toString()));
                continue;
            }
            result.append(c);
            i++;
        }
View Full Code Here

TOP

Related Classes of org.teavm.classlib.java.io.TByteArrayOutputStream

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.