자바 hdfs 파일 삭제 예

1277 단어
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;

import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.util.Progressable;
public class DeleteDirHdfs {
public static void main(String[] args) throws Exception { try { String dst = "hdfs://192.168.0.170:9000/test02"; Configuration conf = new Configuration();
/ / ugi 설정, 프로그램 으로 hdfs 파일 삭제, ugi 설정, 권한 부족 방지
conf.set("hadoop.job.ugi", "zaixing,cug-tbauction,#taobao1234");
FileSystem fs = FileSystem.get(URI.create(dst), conf); fs.delete(new Path(dst),true); fs.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
System.out.println("SUCCESS");
}
}
}

좋은 웹페이지 즐겨찾기