Wednesday, January 4, 2017

How to rename jar file name to new name or modify the existing jar file name ?



Put the jar file in particular location in your machine and provide that path in your code as I have provided as D://apache-tomcat-8.0.39//webapps//examples//test


_____________________________________________________________________________________


Code:

_____________________________________________________________________________________

import java.io.File;

public class Test {
       public static void main(String[] args) {
              File dir = new File("D://apache-tomcat-8.0.39//webapps//examples//test");
              File[] filesList = dir.listFiles();
              int i=1;
             
              for (File file : filesList) {
                     if (file.isFile()) {
                           File oldfile =new File("D://apache-tomcat-8.0.39//webapps//examples//test//"+file.getName());
                           File newfile =new File("D://apache-tomcat-8.0.39//webapps//examples//test//"+file.getName().replaceAll("__V1.0.jar", ".jar"));
                           oldfile.renameTo(newfile);
                           System.out.println(file.getName().replaceAll("__V1.0.jar", ".jar"));
                                 
                     }
              }
        }
}

_____________________________________________________________________________________

No comments:

Post a Comment

Fixing yum command on linux

You may find yourself having to fix more packages. So you can just remove everything you had installed via  pip and reinstall everythin...