Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How HDFS FileStatus retrieves information about files and directories

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you how HDFS FileStatus to retrieve files and directory related information, I hope you have something to gain after reading this article, let's discuss it together!

package com.lango.mapreduce.example.chainmapper;import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileStatus;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;public class Test { public static void main(String[] args) throws IOException { String INPUT_PATH = "/access_data"; Test.iterFs(INPUT_PATH); } private static void iterFs(String INPUT_PATH) throws IOException { Configuration conf = new Configuration(); conf.set("fs.default.name", "hdfs://master:9000"); FileSystem hdfs = FileSystem.get(conf); Path listf = new Path(INPUT_PATH); FileStatus stats[] = hdfs.listStatus(listf); for(FileStatus f : stats){ String fsPath = f.getPath().toString(); System.out.println(fsPath); if(f.isDir()){ iterFs(fsPath); } else { System.out.println(fsPath); } } }} After reading this article, I believe you have a certain understanding of "HDFS FileStatus how to retrieve file and directory related information". If you want to know more about it, please pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report