Here you can find the source of percentEncode(String value, String encoding)
public static String percentEncode(String value, String encoding) throws UnsupportedEncodingException
//package com.java2s; // | Licensed under the Apache License, Version 2.0 (the "License"); import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static String percentEncode(String value, String encoding) throws UnsupportedEncodingException { return value != null ? URLEncoder.encode(value, encoding) .replace("+", "%20").replace("*", "%2A") .replace("%7E", "~") : null; }/*from w w w . j a va 2 s. c o m*/ }