Here you can find the source of utf8urlencode(String text)
public static String utf8urlencode(String text)
//package com.java2s; //License from project: Open Source License import java.nio.charset.StandardCharsets; public class Main { public static String utf8urlencode(String text) { StringBuilder result = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (c <= 255) { result.append(c);/*from w w w. j a v a2s. com*/ } else { byte[] b = new byte[0]; try { b = Character.toString(c).getBytes(StandardCharsets.UTF_8); } catch (Exception ignored) { } for (byte aB : b) { int k = aB; if (k < 0) { k += 256; } result.append("%").append(Integer.toHexString(k).toUpperCase()); } } } return result.toString(); } }