Java tutorial
import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; public class Main { public static void main(String[] args) throws Exception { Path newFile = FileSystems.getDefault().getPath("C:/home/docs/newFile.txt"); Path copiedFile = FileSystems.getDefault().getPath("C:/home/docs/copiedFile.txt"); Files.createFile(newFile); System.out.println("File created successfully!"); Files.copy(newFile, copiedFile); System.out.println("File copied successfully!"); Files.copy(newFile, copiedFile, StandardCopyOption.REPLACE_EXISTING); } }