A文件:
as1
dfg1
hjkl1
逐行讀取A文件的內容,將1替換成 一 後將替換後的內容寫到B文件中
BufferedReader readBuffer = new BufferedReader(new FileReader( new File("D:/aaaa.txt")));
BufferedWriter write = new BufferedWriter(new FileWriter(new File("D:/bbbb.txt")));
String line = readBuffer.readLine();
while(line!=null){
write.write(line.replaceAll("1", "替換後")+"\r\n");
line = readBuffer.readLine();
}
write.flush();
不謝;