Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import java.nio.charset.Charset;

import android.text.TextUtils;

public class Main {

    public static String decodeURL(String s) {
        return decodeURL(s, null);
    }

    public static String decodeURL(String s, String charsetName) {
        if (s == null) {
            return null;
        }
        try {
            if (TextUtils.isEmpty(charsetName)) {
                charsetName = Charset.defaultCharset().displayName();
            }
            return URLDecoder.decode(s, charsetName);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
}