in src/main/java/com/aliyun/oss/internal/OSSDownloadOperation.java [783:813]
private static void moveFile(final File srcFile, final File destFile) throws IOException {
if (srcFile == null) {
throw new NullPointerException("Source must not be null");
}
if (destFile == null) {
throw new NullPointerException("Destination must not be null");
}
if (!srcFile.exists()) {
throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
}
if (srcFile.isDirectory()) {
throw new IOException("Source '" + srcFile + "' is a directory");
}
if (destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' is a directory");
}
if (destFile.exists()) {
if (!destFile.delete()) {
throw new IOException("Failed to delete original file '" + srcFile + "'");
}
}
final boolean rename = srcFile.renameTo(destFile);
if (!rename) {
copyFile(srcFile, destFile);
if (!srcFile.delete()) {
throw new IOException(
"Failed to delete original file '" + srcFile + "' after copy to '" + destFile + "'");
}
}
}