Here you can find the source of copyContents(Path from, Path to)
public static void copyContents(Path from, Path to) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void copyContents(Path from, Path to) throws IOException { if (to == null || from == null) return; if (Files.exists(to)) Files.delete(to);/* www . j a v a 2 s . c o m*/ if (!from.toFile().renameTo(to.toFile())) throw new IOException("Could not move " + from.toFile().getPath() + " to " + to.toFile().getPath()); if (Files.exists(from)) Files.delete(from); } }