java代码
@Test
public void delete() throws Exception{
//获取文件系统
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(new URI("hdfs://hadoop1:8020"), config, "root");
/*
删除
第二个参数:删除文件夹时有效,为true表示删除该文件夹,为false会抛异常。
*/
fs.delete(new Path("/test"), true);
//关闭资源
fs.close();
}