首页 > 其他 > 详细

递归获取包下的class文件

时间:2018-09-02 13:10:34      阅读:212      评论:0      收藏:0      [点我收藏+]

```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文件

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!