实例:
lx1:
import org.apache.commons.io.FileUtils; import java.io.File;
import java.io.IOException; public class CopyDome {
public static void main(String[] args) throws Exception {
lx3();
}
public static void lx3() throws Exception {
//复制文件夹。
FileUtils.copyDirectoryToDirectory(new File("D:\\17"),new File("C:\\17"));
}
lx2:
public static void lx2() throws Exception {
// 复制文件
FileUtils.copyFile(new File("D:\\lxr.txt"),new File("c:\\lxr.txt"));
}
lx3:
public static void lx1() throws IOException {
//将字符串直接写到文件中
FileUtils.writeStringToFile(new File("D:\\ja.txt"),"春天来哦了");
}
}