标签:文件拷贝到hdfs上并显示进度 already exists as a
把程序打成jar包放到Linux上成功后出现:打印出来,你所要打印的字符。
package com.clq.hdfs; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; 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 FileCopyWithProgress { //******************************** //把本地的一个文件拷贝到hdfs上 //******************************** public static void main(String[] args) throws IOException { String localSrc = args[0]; String dst = args[1]; InputStream in = new BufferedInputStream(new FileInputStream(localSrc)); Configuration conf = new Configuration(); FileSystem fs = FileSystem.get(URI.create(dst), conf); FSDataOutputStream out = fs.create(new Path(dst), new Progressable() { @Override public void progress() { System.out.print("."); } }); IOUtils.copyBytes(in, out, conf, true); } }
用java程序把本地的一个文件拷贝到hdfs上并显示进度,布布扣,bubuko.com
标签:文件拷贝到hdfs上并显示进度 already exists as a
原文地址:http://blog.csdn.net/u012516914/article/details/38121873