Here you can find the source of copyFile(File source, File target)
public static void copyFile(File source, File target)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; public class Main { public static void copyFile(File source, File target) { copyFile(source.toPath(), target.toPath()); }// ww w . ja v a2 s. co m public static void copyFile(Path source, Path target) { try { Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { JOptionPane.showMessageDialog(new JFrame(""), e.getMessage(), "something went wrong, very very wrong", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }