导入第三方jar:commons-io
@Test public void test7() throws IOException { File srcFile = new File("hello.txt"); File destFile = new File("hello2.txt"); //FileUtils.copyFile(srcFile,destFile);//复制文件 String data = FileUtils.readFileToString(srcFile, "UTF-8");//读文件 System.out.println(data); FileUtils.writeStringToFile(destFile,"你好333","UTF-8",true);//写文件,文件不存在时会自动创建 }
标签:文件,srcFile,destFile,File,FileUtils,工具,txt From: https://www.cnblogs.com/ixtao/p/16651577.html