Java Path Copy nio copyFile(String srcPath, String destPath)

Here you can find the source of copyFile(String srcPath, String destPath)

Description

copy File

License

Open Source License

Declaration

private static void copyFile(String srcPath, String destPath) throws Throwable 

Method Source Code

//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);
    }
}

Related

  1. copyFile(Path source, Path target, boolean okToOverwrite, boolean preserveAttributes)
  2. copyFile(Path source, Path target, boolean prompt, boolean preserve)
  3. copyFile(Path source, Path target, boolean prompt, boolean preserve)
  4. copyFile(Path source, Path target, boolean prompt, boolean preserve)
  5. copyFile(Path srcFile, Path srcDir, Path dstDir)
  6. copyFile(String urlPath, String outFile)
  7. copyFileFromResourcesToServer(String resourceFile, Path targetDirectory, boolean override)
  8. copyFiles()
  9. copyFiles(String srcPath, String destPath)