标签:cep 简单的 throws exception where aio user fread eve
已经讲了写入和读取了,那么想要把一个文件的内容复制到另一个文件呢
不说太多,直接见代码
public static void copyFile(String srcFilename, String destFilename) throws IOException { FileReader fReader = new FileReader(srcFilename); FileWriter fWriter = new FileWriter(destFilename); char[] buffer = new char[1024]; int len = 0; while((len = fReader.read(buffer)) != -1) { fWriter.write(buffer); } fReader.close(); fWriter.close(); System.out.println("done"); }
然后,调用的时候是这样
copyFile("C:\\Users\\Administrator\\Desktop\\whereveryouare.txt", "C:\\Users\\Administrator\\Desktop\\Favourite.txt");
最简单的复制就这样了。
标签:cep 简单的 throws exception where aio user fread eve
原文地址:https://www.cnblogs.com/zdsmeetheron190227/p/10741484.html