import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; /*** * @author */ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class DeleteFolder { public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException { Configuration conf=new Configuration(); //注意修改为自己的IP URI uri=new URI("hdfs://192.168.1.100:9000"); FileSystem fs=FileSystem.get(uri,conf,"hadoop"); //删除目录,如果是空的路径,可以忽略第二个参数 fs.delete(new Path("/user/hadoop/ccqq/qq/"),true); /** * /user/hadoop/ccqq/qq * /user/hadoop/ccqq/qq/ 二者无区别,效果均同 */ } }