1.查看HDFS下所有的文件或目录 

 1 package Hdfs;
 2 
 3 import java.io.IOException;
 4 import java.net.URI;
 5 import org.apache.hadoop.conf.Configuration;
 6 import org.apache.hadoop.fs.FileStatus;
 7 import org.apache.hadoop.fs.FileSystem;
 8 import org.apache.hadoop.fs.Path;
 9 
10 public class ListFiles {
11     public static void main(String[] args) {
12         String uri = "hdfs://neusoft-master:9000/user";
13         Configuration conf = new Configuration();
14         try {
15             FileSystem fs = FileSystem.get(URI.create(uri), conf);
16             Path Path = new Path(uri);
17             FileStatus[] status = fs.listStatus(Path);
18             for (int i = 0; i < status.length; i++) {
19                 System.out.println(status[i].getPath().toString());
20             }
21             fs.close();
22         } catch (IOException e) {
23             e.printStackTrace();
24         }
25     }
26 }
查看HDFS下所有的文件

相关文章:

  • 2021-11-18
  • 2021-10-16
  • 2021-10-09
  • 2021-11-18
  • 2021-04-21
  • 2021-11-18
  • 2021-08-23
  • 2021-11-20
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-09-03
  • 2021-05-15
相关资源
相似解决方案