您的位置:首页 > 编程语言 > Java开发

java 修改文件名

2014-10-23 16:23 190 查看
// 修改文件名

public static boolean modifyFileName(String serverPath, String oldFileName,
String newLoginNo) {
String oldPath = serverPath + "/" + oldFileName;
String newPath = serverPath + "/" + newLoginNo + "-"
+ oldFileName.substring(oldFileName.indexOf('-') + 1);
File oldFile = new File(oldPath);
File newFile = new File(newPath);
if (oldFile.renameTo(newFile)) {
return true;
} else {
return false;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: