Java List Replace replacePositions(StringBuffer c, int origLength, String string, List positions)

Here you can find the source of replacePositions(StringBuffer c, int origLength, String string, List positions)

Description

replace Positions

License

Open Source License

Declaration

private static void replacePositions(StringBuffer c, int origLength, String string, List positions) 

Method Source Code

//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;
        }
    }
}

Related

  1. replaceInList(T a, T b, List list)
  2. replaceList(String v, String[] patterns, String[] values)
  3. replaceNpcId(final List npcListSqlLines, final int lineIndex, final int newNpcId, final boolean markAsGuess)
  4. replaceOrAdd(List list, T object)
  5. replacePolUtilsName( final List npcListSqlLines, final int lineIndex, final String name)