码迷,mamicode.com
首页 > 其他好文 > 详细

递归获取包下的class文件

时间:2018-09-02 13:17:56      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:new   name   thread   lse   string   main   tor   rect   ogr   

```java(这个居然隐藏不了)

public class TestUrl {


public static void main(String[] args) {
    String pageName = "ogr.test";//包路径
    fileRecursive(pageName);
}



public static  void fileRecursive(String pageName) {
    URL url = Thread.currentThread().getClass().getResource("/" + pageName.replaceAll("\\.", "/"));//把/代替成.
    File file = new File(url.getFile());
    for(File tempFile: file.listFiles()){
        if(tempFile.isDirectory()){
            fileRecursive(pageName+"."+tempFile.getName());
        }else{
            System.out.println(pageName+"."+tempFile.getName());
        }
    }

}

}

递归获取包下的class文件

标签:new   name   thread   lse   string   main   tor   rect   ogr   

原文地址:https://www.cnblogs.com/jinjian91/p/9573479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!