IDEAjava文件重新命名

Python015

IDEAjava文件重新命名,第1张

1.右键model 然后选择refactor-->rename--->选择rename module-->ok

2.file-->project structure-->修改name为新model名

3.修改pom文件中旧项目名替换为新项目名

4.修改文件名,刷新项目OK

/**

* 修改文件名

* @param oldFilePath 原文件路径

* @param newFileName 新文件名称

* @param overriding 判断标志(如果存在相同名的文件是否覆盖)

* @return

*/

public static boolean renameFile(String oldFilePath,String newFileName,boolean overriding){

File oldfile = new File(oldFilePath)

if(!oldfile.exists()){

return false

}

String newFilepath = oldfile.getParent()+File.separator+newFileName

File newFile = new File(newFilepath)

if(!newFile.exists()){

return oldfile.renameTo(newFile)

}else{

if(overriding){

newFile.delete()

return oldfile.renameTo(newFile)

}else{

return false

}

}

}

原文链接:网页链接

如有帮助请采纳(不懂请提问),可以看我主页,欢迎来交流学习;