Here you can find the source of copyFile(Path source, Path target, boolean prompt, boolean preserve)
static void copyFile(Path source, Path target, boolean prompt, boolean preserve)
//package com.java2s; import java.nio.file.*; import java.io.IOException; public class Main { /**// w ww.ja v a 2 s.c om * Copy source file to target location. If {@code prompt} is true then * prompt user to overwrite target if it exists. The {@code preserve} * parameter determines if file attributes should be copied/preserved. */ static void copyFile(Path source, Path target, boolean prompt, boolean preserve) { if (!prompt || Files.notExists(target)) { try { Files.copy(source, target); } catch (IOException x) { System.err.format("Unable to copy: %s: %s%n", source, x); } } } }