decode string in UTF-8 - Android java.lang

Android examples for java.lang:String UTF-8

Description

decode string in UTF-8

Demo Code

import android.graphics.Paint;
import android.text.TextPaint;
import android.text.TextUtils;
import android.widget.TextView;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String decode(String s) {
        if (s == null) {
            return "";
        }//  ww w .  jav  a2  s  .c  o  m
        try {
            return URLDecoder.decode(s, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

}

Related Tutorials