Java examples for Big Data:HDF
delete HDFS file or directory
package Hdfs;/*w w w.ja v a 2 s. c o m*/ import java.io.IOException; import java.net.URI; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class DeleteFile { public static void main(String[] args) { String uri = "hdfs://neusoft-master:9000/user/root/test1"; Configuration conf = new Configuration(); try { FileSystem fs = FileSystem.get(URI.create(uri), conf); Path delPath = new Path( "hdfs://neusoft-master:9000/user/root/test1"); boolean isDeleted = fs.delete(delPath, false); //boolean isDeleted = fs.delete(delPath,true);//???? System.out.println(isDeleted); } catch (IOException e) { e.printStackTrace(); } } }