Here you can find the source of replaceInLines(List
public static List<String> replaceInLines(List<String> lines, String from, String to, int fromIndex, int toIndex)
//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; } }