1 @Test 2 public void testDelete() throws IOException, InterruptedException, URISyntaxException { 3 4 //1.获取文件系统 5 Configuration configuration = new Configuration(); 6 FileSystem fs = FileSystem.get(new URI("hdfs://192.168.12.161:9000"), configuration, "hadoop"); 7 //2.执行删除 8 fs.delete(new Path("/zxc.txt"),true); 9 //3.关闭资源 10 fs.close(); 11 }
new path 里也可以填写文件路径