Android examples for java.net:URL
url Encode in UTF-8
import android.content.Context; import android.content.res.AssetManager; import android.os.Environment; import android.text.format.DateFormat; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.ArrayList; public class Main{ public static String urlEncode(String src) { try {/*from w ww . j a v a2 s. c om*/ String str = URLEncoder.encode(src, "UTF-8"); if (str.indexOf("+") > -1) { str = str.replace("+", "%20"); } return str; } catch (Exception e) { // TODO: handle exception LogUtil.e(e.getMessage()); return ""; } } }