Package com.state.util;
Import Java.io.File;
public class Versionctrl {
private static String version= "1.02";//Version number
public static String Getvesrsion () {
return version;
}
/**
* Version control function, each update version of the function will update the JS and CSS under the state style
* @param arg
*/
public static void Main (String arg[]) {
String url=system.getproperty ("User.dir");
String jsurl=url+ "\\src\\main\\webapp\\js\\state";//Get JS Path
String cssurl=url+ "\\src\\main\\webapp\\css";//Get CSS Path
System.out.println (Jsurl);
File Jsfile=new file (jsurl);
File Cssfile=new file (cssurl);
try {
Showallfiles (Jsfile);
Showallfiles (Cssfile);
} catch (Exception e) {
E.printstacktrace ();
}
}
Final static void Showallfiles (File fl) throws exception{
String[] Files=fl.list ();
File F=null;
String filename= "";
for (String file:files) {
F=new File (Fl,file);
Filename=f.getname ();
if (Filename.contains (". js")) {
Note that you need to change the version number at the same time to replace the last version number
F.renameto (New File (Fl.getabsolutefile () + "//" +filename.replace ("1.02.js", version+ ". js"));
}else if (Filename.contains (". css")) {
F.renameto (New File (Fl.getabsolutefile () + "//" +filename.replace ("1.02.css", version+ ". css"));
}
if (F.isdirectory ()) {
try{
Showallfiles (f);
}catch (Exception e) {
}
}
}
}
}
Versioning, Batch modification of file renaming