设为首页 加入收藏

TOP

java   正则匹配 HDFS路径后获取目录下文件
2019-03-15 00:18:01 】 浏览:79
Tags:java   正则 匹配 HDFS 路径 获取 目录 文件
public static void main(String[] args) {
        URI uri = URI.create("hdfs://cdh-master:8020");
        FileSystem hdfs = null;
        Path path = new Path("/hiaAnalyticsService");
        try {
            hdfs = FileSystem.get(uri, conf, "hdfs");
            FileStatus[] files = hdfs.globStatus(path);
            for (FileStatus file : files) {
                //System.out.println(file.getPath());
                if (file.isDirectory()) {
                    RemoteIterator<LocatedFileStatus> iterator = hdfs.listFiles(file.getPath(), false);
                    while (iterator.hasNext()) {
                        LocatedFileStatus fileStatus = iterator.next();
                        Path fullPath = fileStatus.getPath();
                        System.out.println(fullPath);
                    }
                } else {
                    System.out.println(file.getPath());
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Hadoop _ Hdfs   java.io.IO.. 下一篇centos-7 部署hadoop2.5.1 >&g..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目