美文网首页
Java 读取所有文件地址

Java 读取所有文件地址

作者: Jin110 | 来源:发表于2019-04-18 11:01 被阅读0次
    public static void getAllFileName(String path) {
        File file = new File(path);
        File[] files = file.listFiles();
        for (File ff : files) {
            if (ff.isFile()) {
                String name = ff.getName();
                String rootPath = ff.getParent();
                System.out.println(rootPath + name);
            }
            if (ff.isDirectory()) {
                getAllFileName(ff.getAbsolutePath());
            }
        }
    }

    public static void main(String[] args) {
        String path = "/Users/jin/Desktop";
        getAllFileName(path);
    }

相关文章

网友评论

      本文标题:Java 读取所有文件地址

      本文链接:https://www.haomeiwen.com/subject/mijzwqtx.html