[英]Load hdfs partitions files list
我正在编写一个小程序来使用java加载hdfs文件。 当我运行代码时,我从hdfs获取文件列表。 但是,我想单独获取分区文件。 例如,部分00000文件。
以下是示例代码:
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://localhost");
FileSystem hdfs = FileSystem.get(new URI(
"hdfs://localhost"), conf);
RemoteIterator<LocatedFileStatus> fsStatus = hdfs.listFiles(
new Path("/hdfs/path"), true);
while (fsStatus.hasNext()) {
String path = fsStatus.next().getPath().toString();
System.out.println(path.matches("part-"));
}
我假设您要打印该路径,而不是它匹配的事实
if (path.startsWith("part-")) {
System.out.println(path);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.