IO编程__缓冲字符流__输入输出
Posted 18513757531
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IO编程__缓冲字符流__输入输出相关的知识,希望对你有一定的参考价值。
一、代码如下
package www.tainiu.wenjian; 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 af__FileHuanZiFuLiu__V1 { public static void main(String[] args) { // TODO Auto-generated method stub BufferedReader br= null; BufferedWriter bw= null; try { FileReader fr= new FileReader("d:\\Test.txt"); br= new BufferedReader(fr); FileWriter fw= new FileWriter("e:\\Test__1.txt"); bw= new BufferedWriter(fw); String s= ""; while((s=br.readLine()) != null) { //System.out.println(s); bw.write(s + "\r\n"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try {br.close();bw.close();} catch (IOException e) {e.printStackTrace();} } } }
package www.tainiu.wenjian; 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 af__FileHuanZiFuLiu__V2 { public static void main(String[] args) { // TODO Auto-generated method stub BufferedReader br= null; BufferedWriter bw= null; try { //FileReader fr= new FileReader("d:\\Test.txt"); br= new BufferedReader(new FileReader("d:\\Test.txt")); //FileWriter fw= new FileWriter("e:\\Test__1.txt"); bw= new BufferedWriter(new FileWriter("e:\\Test__2.txt")); String s= ""; while((s=br.readLine()) != null) { //System.out.println(s); bw.write(s + "\r\n"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try {br.close();bw.close();} catch (IOException e) {e.printStackTrace();} } } }
以上是关于IO编程__缓冲字符流__输入输出的主要内容,如果未能解决你的问题,请参考以下文章