Here you can find the source of replacePositions(StringBuffer c, int origLength, String string, List positions)
private static void replacePositions(StringBuffer c, int origLength, String string, List positions)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w w w . j a v a2s . c o m * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.Iterator; import java.util.List; public class Main { private static void replacePositions(StringBuffer c, int origLength, String string, List positions) { int offset = 0; for (Iterator iter = positions.iterator(); iter.hasNext();) { int position = ((Integer) iter.next()).intValue(); c.replace(offset + position, offset + position + origLength, string); offset += string.length() - origLength; } } }