import java.io.*;
public class T {
public static void main(String[] args) {
try {
String a = "D:\\.ftl";
BufferedReader bufReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(a))));//数据流读取文件
StringBuffer strBuffer = new StringBuffer();
String empty = "";
String tihuan = "";
int dd = 37;
for (String temp = null; (temp = bufReader.readLine()) != null; temp = null) {
System.out.println(temp);
System.out.println("---------------------------");
if (temp.indexOf("yanyan") != -1) { //判断当前行是否存在想要替换掉的字符 -1表示存在
int i = temp.indexOf("yanyan");
tihuan = temp.substring(i, i + 6);
empty = "id="a" + dd + "" name="a" + dd + "" value="${scData.a" + dd + "!''}"";
temp = temp.replace(tihuan, empty);//替换为你想要的东东
System.out.println(temp);
dd++;
}
strBuffer.append(temp);
strBuffer.append(System.getProperty("line.separator"));//行与行之间的分割
}
bufReader.close();
PrintWriter printWriter = new PrintWriter("D:/EntNatureDistributionDAO.txt");//替换后输出的文件位置
printWriter.write(strBuffer.toString().toCharArray());
printWriter.flush();
printWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}