decode String with URLDecoder - Android java.net

Android examples for java.net:URL

Description

decode String with URLDecoder

Demo Code

import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Locale;

public class Main{

    /**/*from w ww  .  j  a  v  a  2s.co  m*/
     * Decode a string
     *
     * @param str
     * @return
     */
    public static String decodeString(String str) {
        try {
            return URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return str;
        }
    }

}

Related Tutorials