1. package
2. import
3. import
4. import
5.   
6. /**
7.  * 读取目录及子目录下指定文件名的路径, 返回一个List
8.  */
9.   
10. public class
11. private static Logger logger = Logger.getLogger(FileViewer.class);  
12.   
13. /**
14.      * @param path
15.      *            文件路径
16.      * @param suffix
17.      *            后缀名, 为空则表示所有文件
18.      * @param isdepth
19.      *            是否遍历子目录
20.      * @return list
21.      */
22. public static
23. boolean
24. new
25. new
26. return
27.     }  
28.   
29. private static
30. boolean
31. // 若是目录, 采用递归的方法遍历子目录
32. if
33.             File[] t = f.listFiles();  
34.   
35. for (int i = 0; i < t.length; i++) {  
36. if
37.                     listFile(lstFileNames, t[i], suffix, isdepth);  
38.                 }  
39.             }  
40. else
41.             String filePath = f.getAbsolutePath();  
42. if (!suffix.equals("")) {  
43. int begIndex = filePath.lastIndexOf("."); // 最后一个.(即后缀名前面的.)的索引
44. "";  
45.   
46. if (begIndex != -1) {  
47. 1, filePath  
48.                             .length());  
49. if
50.                         lstFileNames.add(filePath);  
51.                     }  
52.                 }  
53. else
54.                 lstFileNames.add(filePath);  
55.             }  
56.         }  
57. return
58.     }  
59.       
60. public static void
61. "E:\\mulejar","",true);  
62.         System.out.println(list.size());  
63.         System.out.println(list);  
64.     }  
65. }