📄 renamefile.java
字号:
package net.aetherial.gis.test.tools;
import java.io.File;
import java.util.Vector;
import net.aetherial.gis.our.auto.Auto;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class RenameFile extends Auto{
public RenameFile() {
}
/**
* 如果文件的后缀名,满足给定的suffix时,返回true;
*/
public boolean isSatisfySuffix(File f,String suffix){
/**
* 设置条件
*/
String fileName = f.getAbsolutePath();
String fSuffix = fileName.substring(fileName.length()-4,fileName.length());
if (fSuffix.equals(suffix)) {
return true;
}else{
return false;
}
}
private File getNewAbsolutePathFile(File f,String newSuffix){
File nf = null;
String fileName = f.getAbsolutePath();
String newFile = fileName.substring(0,fileName.length()-4) + newSuffix;
nf = new File(newFile);
return nf;
}
public void run(){
if (this.input == null) {
System.out.println("没有设置目录!");
return;
}
File newFile = null;
for (int i = 0; i < this.input.length; i++) {
if (this.isSatisfySuffix(this.input[i],".jad")) {
newFile = this.getNewAbsolutePathFile(this.input[i],".java");
System.out.println("修改文件名:" + this.input[i].getAbsolutePath() + " -> " + newFile.getName());
this.input[i].renameTo(newFile);
}
}
}
public static void main(String args[]){
RenameFile rf = new RenameFile();
rf.setInputAllDirectory("E:\\test\\1\\org");
rf.run();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -