public class TestBuffInput {
/**高级流copy文件,读取文件中内容打印到控制台*/
public void copy(String from,String to) throws IOException{
/*构建高级输入流
*InputStream in = new FileInputStream("e:\\TestProp");
*Reader read = new InputStreamReader(in);
*BufferedReader bu = new BufferedReader(read);
* */
//把上面三句封装成一句
BufferedReader br = new BufferedReader(new InputStreamReader (new FileInputStream(from)));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter (new FileOutputStream(to)));
String s = null;
while ((s = br.readLine())!=null){
System.out.println(s); //输出到控制台
bw.write(s+"\r\n"); //换行
bw.flush(); //刷新此缓冲的输出流。
}
br.close();
bw.close();
}
public static void main(String[] args) throws IOException {
TestDataInput tes = new TestDataInput();
tes.copy("e:\\peixun\\Tet.txt","e:\\test.txt");
}
}