讀取Jar包資料夾裡的所有jar包檔名
阿新 • • 發佈:2018-12-18
package tool; import java.io.File; public class DealJarFolder { public static void main(String[] args){ String filePath = "C:/Users/Administrator/Desktop/MyJarFolder"; searchJarName(filePath); } private static void searchJarName(String filePath){ File folder = new File(filePath); File[] fileArray = folder.listFiles(); if(folder.isDirectory()){ for(int i = 0;i < fileArray.length;i++){ File file = fileArray[i]; String fileName = file.getName(); if(file.isDirectory()){ searchJarName(filePath + "/fileName"); } if(file.isFile()){ if(fileName.split("\\.jar").length != 0){ fileName = fileName.split("\\.jar")[0]; } System.out.println(fileName); } } } } }