|
public static void main(String[] args) throws Exception {
String localSrc = "/home/ganliang/test_fileCopyWithProgress.txt";//本地文件
String dst = "hdfs://localhost:9000/user/ganliang/hadoop_in/test_fileCopyWithProgress.txt";//复制到hdfs目录下
InputStream in = new BufferedInputStream(new FileInputStream(localSrc));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(dst), conf);
OutputStream out = fs.create(new Path(dst), new Progressable() {//进度条信息
public void progress() {
System.out.print(".");
}
});
IOUtils.copyBytes(in, out, 4096, true);//复制
}
|
|
|