Java List Replace replaceInLines(List lines, String from, String to, int fromIndex, int toIndex)

Here you can find the source of replaceInLines(List lines, String from, String to, int fromIndex, int toIndex)

Description

replace In Lines

License

Open Source License

Declaration

public static List<String> replaceInLines(List<String> lines, String from, String to, int fromIndex,
            int toIndex) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> replaceInLines(List<String> lines, String from, String to) {
        return replaceInLines(lines, from, to, -1, -1);
    }/*from   ww w  . j  ava  2  s .c om*/

    public static List<String> replaceInLines(List<String> lines, String from, String to, int fromIndex,
            int toIndex) {
        List<String> list = new ArrayList<String>();
        if (fromIndex == -1)
            fromIndex = 0;
        if (toIndex == -1)
            toIndex = lines.size();
        for (int i = 0; i < lines.size(); i++) {
            String line = lines.get(i);
            String outputLine = line;
            if (i >= fromIndex && i < toIndex) {
                outputLine = line.replace(from, to);
            }
            list.add(outputLine);
        }
        return list;
    }
}

Related

  1. replaceAndAdd(List par3List, String translateToLocal)
  2. replaceAtSymbol(String s, List params)
  3. replaceColons(List unstructuredSentences)
  4. replaceFields(Map mapFields, String changeStr, List listString)
  5. replaceIgnoreList(String text)
  6. replaceInList(T a, T b, List list)
  7. replaceList(String v, String[] patterns, String[] values)
  8. replaceNpcId(final List npcListSqlLines, final int lineIndex, final int newNpcId, final boolean markAsGuess)
  9. replaceOrAdd(List list, T object)