if (in.isDirectory()) {
ArrayList<File> failed = new ArrayList<File>();
copyDir(in, out, overwrite, failed);
// Failed any?
if (failed.size() != 0)
throw new IORException("Could not copy files: "
+ Printer.toString(failed));
return out;
}
if (out.isDirectory()) {
out = new File(out, in.getName());
}
try {
if (out.exists() && !overwrite)
throw new IORException("Copy failed: " + out
+ " already exists.");
// TODO use NIO for efficiency!
copy(new FileInputStream(in), out);
return out;
} catch (IOException e) {
throw new IORException(e.getMessage() + " copying "
+ in.getAbsolutePath() + " to " + out.getAbsolutePath());
}
}