rename(newFile, oldFile);
} catch (Exception ex) {
j2log(null, null, ex);
}
return newFile;
}
/**
* rename 文件重命名
*
* @param to
* @param from
* @return
*/
public static File rename(File from, File to) {
try {
String newPath = to.getPath();
String oldPath = from.getPath();
if (!oldPath.equals(newPath)) {
if (!to.exists()) {
from.renameTo(to);
}
}
} catch (Exception ex) {
j2log(null, null, ex);
}
return to;
}
/**
* mv 移动文件
*
* @param fileName
* @param source
* @param destination
* @param cover
*/
public static void mv(String fileName, String source, String destination, boolean cover) {
try {
if (!source.equals(destination)) {
File oldFile = new File(combainPath(source, fileName));
File newFile = new File(combainPath(destination, fileName));
mv(oldFile, newFile, cover);
}
} catch (Exception ex) {
j2log(null, null, ex);
}
}
/**
* mv 移动文件
*
* @param source
* @param destination
* @param cover
*/
public static void mv(String source, String destination, boolean cover) {
try {
if (!source.equals(destination)) {
File oldFile = new File(source);
File newFile = new File(destination);
mv(oldFile, newFile, cover);
}
} catch (Exception ex) {
j2log(null, null, ex);
}
}
/**
* mv 移动文件
*
* @param source
* @param destination
* @param cover
*/
public static void mv(File source, File destination, boolean cover) {
try {
if (!source.exists()) {
throw new FileNotFoundException();
}
StringBuilder fileName = new StringBuilder(source.getName());