Here you can find the source of replaceInvalid(String uri, Map
private static String replaceInvalid(String uri, Map<String, String> reps)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { private static String replaceInvalid(String uri, Map<String, String> reps) { // replace invalid characters StringBuilder builder = new StringBuilder(); for (char curChar : uri.toCharArray()) { String charStr = String.valueOf(curChar); if (reps.containsKey(charStr)) { builder.append("%" + reps.get(charStr)); } else { builder.append(charStr); }/* w ww . ja va2s.c o m*/ } return builder.toString(); } }