Versioning, Batch modification of file renaming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.