FileUtil.delete(dest);
} catch (IOException ioe) {
String msg = "moving " + src.getPath() + " to "
+ dest.getPath() + " failed";
log.debug(msg);
throw new FileSystemException(msg, ioe);
}
}
File destParent = dest.getParentFile();
if (!destParent.exists()) {
// create destination parent folder first
if (!destParent.mkdirs()) {
String msg = "moving " + src.getPath() + " to "
+ dest.getPath() + " failed";
log.debug(msg);
throw new FileSystemException(msg);
}
}
// now we're ready to move/rename the file/folder
if (!src.renameTo(dest)) {
String msg = "moving " + src.getPath() + " to "
+ dest.getPath() + " failed";
log.debug(msg);
throw new FileSystemException(msg);
}
}