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.FileSystem;
 7 import org.apache.hadoop.fs.Path;
 8 
 9 public class CheckFileExist {
10     public static void main(String[] args) {
11         String uri = "hdfs://neusoft-master:9000/user/root/test1";
12         Configuration conf = new Configuration();
13         try {
14             FileSystem fs = FileSystem.get(URI.create(uri), conf);
15             Path delPath = new Path(uri);
16             boolean isExists = fs.exists(delPath);
17             System.out.println(isExists);
18         } catch (IOException e) {
19             e.printStackTrace();
20         }
21     }
22 
23 }
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-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-09-03
  • 2021-05-15
相关资源
相似解决方案