Here you can find the source of copyAlways(Path source, Path target)
public static void copyAlways(Path source, Path target) throws IOException
//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); } }