本文主要是介绍采用字符流文件的复制,并用BufferedWriter提高文件的传输速率,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
public class Test06 {public static void main(String[] args) {try (//输入流FileReader fileReader = new FileReader("E:\\IdeaProjects\\aliang\\day03.txt");//输入缓冲流BufferedReader bufferedReader = new BufferedReader(fileReader);//输出流FileWriter fileWriter = new FileWriter("E:\\IdeaProjects\\aliang\\day03.副本.txt");//输出缓冲流BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);){String line;while((line=bufferedReader.readLine())!=null){//一次读取一行数据,返回取到的数据,如果达到末尾则返回nullbufferedWriter.write(line);bufferedWriter.newLine();bufferedWriter.flush();System.out.println(line);}System.out.println("文件复制完成");}catch (Exception e){e.printStackTrace();}} }
这篇关于采用字符流文件的复制,并用BufferedWriter提高文件的传输速率的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!