Here you can find the source of replaceChars(String s, char[] from, char[] to)
public static String replaceChars(String s, char[] from, char[] to)
//package com.java2s; //License from project: Apache License import java.util.Arrays; public class Main { public static String replaceChars(String s, char[] from, char[] to) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); int index = Arrays.binarySearch(from, ch); if (index >= 0) { sb.append(to[index]);/* www . j a v a2s . c o m*/ } else { sb.append(ch); } } return sb.toString(); } }