Skip to content

Instantly share code, notes, and snippets.

@donaldmunro
donaldmunro / copyFile
Created Jun 20, 2012 — forked from mrenouf/copyFile
Efficient file copy in Java (pre-JDK7)
View copyFile
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");
}