Skip to content

Instantly share code, notes, and snippets.

@donaldmunro
donaldmunro / copyFile
Created June 20, 2012 09:51 — forked from mrenouf/copyFile
Efficient file copy in Java (pre-JDK7)
public static void copyFile(File sourceFile, File destFile, final boolean isOverwrite) throws IOException {
if (destFile.isDirectory())
destFile = new File(destFile, sourceFile.getName());
if (destFile.exists())
{
if (isOverwrite)
destFile.delete();
else
throw new IOException(destFile.getAbsolutePath() + " exists");
}