2008年7月28日 星期一

[Java] BufferedReader 和 BufferedWriter 使用方法

import java.io.BufferedReader;
import java.io.BufferedWriter;


Reader rd = new FileReader("abc.txt");
Writer wt = new FileWriter("def.txt");


BufferedReader br = new BufferedReader(rd);
BufferedWriter bw = new BufferedWriter(wt);
String line = null;

while((line = br.readLine()) !=null){
//BufferedWriter user next two line
bw.write(line);
bw.newLine();
System.out.println(line);
}
br.close();

1 則留言:

Unknown 提到...

超有用XD
謝!!