Here you can find the source of copyFile(String srcPath, String destPath)
private static void copyFile(String srcPath, String destPath) throws Throwable
//package com.java2s; //License from project: Open Source License import java.io.File; import java.nio.file.Files; import java.nio.file.StandardCopyOption; public class Main { private static void copyFile(String srcPath, String destPath) throws Throwable { File srcFile = new File(srcPath); File destFile = new File(destPath); if (!destFile.exists()) new File(destPath).mkdirs(); destFile = new File(destPath); Files.copy(srcFile.toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING); }/*from w w w . j a v a 2s . c o m*/ private static void copyFile(File srcFile, File destFile) throws Throwable { if (!destFile.exists()) { new File(destFile.getAbsolutePath()).mkdirs(); destFile = new File(destFile.getAbsolutePath()); } Files.copy(srcFile.toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING); } }