http://11967046.blogspot.tw/2011/06/bufferedreaderbufferedwriter.html
import
java.io.BufferedReader;
import
java.io.BufferedWriter;
import
java.io.FileNotFoundException;
import
java.io.FileReader;
import
java.io.FileWriter;
import
java.io.IOException;
public
class
s11967046 {
public
static
void
main(String[] args) {
FileReader reader =
null
;
FileWriter writer =
null
;
BufferedReader br =
null
;
BufferedWriter bw =
null
;
String data;
try
{
reader =
new
FileReader(
"A.txt"
);
writer =
new
FileWriter(
"B.txt"
,
true
);
br =
new
BufferedReader(reader);
bw =
new
BufferedWriter(writer);
while
((data = br.readLine()) !=
null
){
bw.write(data);
bw.newLine();
}
}
catch
(FileNotFoundException e){
System.out.print(
"檔案找不到"
);
}
catch
(IOException e) {
}
finally
{
try
{
br.close();
bw.close();
}
catch
(IOException e) {
}
}
}
}
沒有留言:
張貼留言