?? filerename.java
字號:
import java.io.*;
public class FileRename {
public static void main(String[] args) {
String targetExtension=".xml";
if(args.length >= 1 ) {//1
String ext =args[0].substring(args[0].indexOf("."));
System.out.println(ext);
if(ext.equalsIgnoreCase(".txt")) {//2
File f = new File(args[0]);
//if the file exists
// then change the filename
if(f.exists()) {//3
args[0]=args[0].replace(ext,targetExtension);
System.out.println(" "+args[0]);
File change = new File(args[0]);
f.renameTo(change);
}//3
//if file does not exists then create a new file
else {//3
try {
f.createNewFile();
args[0]=args[0].replace(ext,targetExtension);
System.out.println(" "+args[0]);
File change = new File(args[0]);
f.renameTo(change);
}//try
catch(IOException ioe) {
}//catch
}//3
}//2
}//1
}//main
}//class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -