Encode URL in utf-8 - Android java.lang

Android examples for java.lang:String UTF-8

Description

Encode URL in utf-8

Demo Code

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String getURLEncodeStr(String url) {
        try {//w w w  .jav  a  2 s.c o  m
            url = URLEncoder.encode(url, "utf-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
        }
        return url;
    }

}

Related Tutorials