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 里也可以填寫文件路徑