Advertisement
Guest User

parseJarfileName

a guest
Jul 7th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public String parseJarfileName(String jarLocation) {
  2.         if(jarLocation == null)
  3.             return ""; // path to jar location is empty,
  4.                        // return so stuff doesn't get messed up
  5.         String jarfileName = ""; // name of the .jar server executable
  6.         for(int i = jarLocation.length(); jarLocation.charAt(i - 1) != '/'; i --) {
  7.             // read the string backwards until a / is found,
  8.             // signaling that the jarfile name has ended
  9.             // as this is done, concatenate the characters of the jarfile name
  10.             jarfileName += jarLocation.charAt(i - 1);
  11.             jarfileName.trim();
  12.             // the jarfile name will be backwards here, so reverse it
  13.             String str = new StringBuilder(jarfileName).reverse().toString();
  14.             jarfileName = str;
  15.         }
  16.         return jarfileName;
  17.     }
  18. // written by 2xedo: twitter.com/2xedo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement