package com.jredu.ch02_lianxi;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class BufferedReaderTest {
public static void main(String[] args) {
BufferedReader br = null;
BufferedWriter bw = null;
StringBuffer sb = new StringBuffer();
try {
br = new BufferedReader(new FileReader(new File("e:\\IO练习专用\\qwer.txt")));
bw = new BufferedWriter(new FileWriter(new File("e:\\IO练习专用\\lianxi.txt")));
int i = 0;
while ((i = br.read())!=-1) {
char ch = (char) i;
sb.append(ch);
}
System.out.println(sb.toString());
bw.write(sb.toString());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
bw.flush();
bw.close();
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}