Here you can find the source of escapeSelected(String str, String chars)
public static String escapeSelected(String str, String chars)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static String escapeSelected(String str, String chars) { chars = "%" + chars; for (int i = 0; i < chars.length(); i++) { String charAsStr = chars.substring(i, i + 1); try { str = str.replace(charAsStr, URLEncoder.encode(charAsStr, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 encoding not found:", e); }//from w w w .j a va 2 s. com } return str; } }