import java.io.BufferedReader;
import java.io.PrintWriter;
利用FileReader把檔案取出,用PrintWriter寫到另一個檔案中
Reader rd = new FileReader("abc.txt");
Writer wt = new FileWriter("def.txt");
通常都以BufferedReader搭配PrintWriter的方式
BufferedReader是以逐行讀出的方式,一行一行讀出abc.txt 中的內容
BufferedReader br = new BufferedReader(rd);
PrintWriter pw = new PrintWriter(wt);
String line = null;
while((line = br.readLine()) !=null){
//PrintWriter user next line(usually use this)
pw.println();
System.out.println(line);
}
br.close();
沒有留言:
張貼留言