缓冲区的简单读取和写入

public class BufferReader_t {

public static void main(String[] args)throws Exception {

    File f=new File("d:/test/a.txt");

    // //就是套几层,这个要自己点源码进去看下,为啥要这样嵌套
	
    BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(new FileInputStream(f)));
	
    BufferedWriter bufferedWriter=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new 
	
	File("d:/test/a_1.txt"))));

    String s=null;
	
    while ((s=bufferedReader.readLine())!=null){
	
        bufferedWriter.write(s);
		
        //写入换行符
		
         bufferedWriter.newLine();
		 
        System.out.println(s);
		
    }
	
    bufferedWriter.close();
	
    bufferedReader.close();
    
}

}

转载于:https://my.oschina.net/u/2511906/blog/3100159

你可能感兴趣的:(c/c++,大数据)