Here you can find the source of replace(char[][] arrays, char character, char[][] replacements)
public static char[][] replace(char[][] arrays, char character, char[][] replacements)
//package com.java2s; /**/*from ww w .j a va 2 s . c o m*/ * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.util.ArrayList; import java.util.List; public class Main { public static String EMPTY_STRING = ""; public static char[][] replace(char[][] arrays, char character, char[][] replacements) { List<char[]> list = new ArrayList<char[]>(); for (char[] array : arrays) { String string = String.valueOf(array); if (string.indexOf(character) >= 0) { for (char[] replacement : replacements) { list.add(string.replaceAll(String.valueOf(character), String.valueOf(replacement)) .toCharArray()); } } else { list.add(array); } } return list.toArray(new char[list.size()][]); } /** * replace in a string a string sequence with another string sequence */ public static String replace(String source, String whatBefore, String whatAfter) { if (null == source || source.length() == 0) { return source; } int beforeLen = whatBefore.length(); if (beforeLen == 0) { return source; } StringBuffer result = new StringBuffer(EMPTY_STRING); int lastIndex = 0; int index = source.indexOf(whatBefore, lastIndex); while (index >= 0) { result.append(source.substring(lastIndex, index)); result.append(whatAfter); lastIndex = index + beforeLen; // get next index = source.indexOf(whatBefore, lastIndex); } result.append(source.substring(lastIndex)); return result.toString(); } }