Not an answer but too long for a comment. I run the code below (from the command line on Windows 7) and it works as expected:
public static void main(String[] args) throws IOException {
Path target = Paths.get("C:/temp/test.txt"); // Returns a path, works ok.
Path tempFile = Files.createTempFile("tempfile", null);
Files.write(tempFile, "abc".getBytes(UTF_8), StandardOpenOption.WRITE);
// Actual copy.
Files.copy(tempFile, target, StandardCopyOption.REPLACE_EXISTING);
// Cleanup.
Files.delete(tempFile);
}
so your problem is not with that code. It may be somewhere else in your code or due to the permissions on the files/folder you are using.