Java Path Copy nio copyAlways(Path source, Path target)

Here you can find the source of copyAlways(Path source, Path target)

Description

copy Always

License

Open Source License

Declaration

public static void copyAlways(Path source, Path target) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

public class Main {
    public static void copyAlways(Path source, Path target) throws IOException {
        if (!Files.exists(target)) {
            Path parent = target.getParent();
            if (Files.notExists(parent)) {
                Files.createDirectories(parent);
            }//from   w w w.  j a v a 2  s  . c  o m
            Files.createFile(target);
        }
        Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
    }
}

Related

  1. copy(Path source, Path target, CopyOption... options)
  2. copy(Path sourcePath, Path destinationPath)
  3. copy(Path sourcePath, Path targetPath)
  4. copy(Path src, Path dest, List globPattern)
  5. copy(String filePath, String fileName)
  6. copyAsTrueTempFile(Path source, FileAttribute... attrs)
  7. copyConfigFile(final String file, final Path dir)
  8. copyContainer(String from, String to, IProgressMonitor monitor)
  9. copyContents(Path from, Path to)