Hadoop将本地文件复制到Hadoop文件系统

代码:

package com.hadoop;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI; import org.apache.hadoop.conf.Configuration;
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 { public static void main(String[] args) throws Exception { String localSrc = args[0];
String dst = args[1]; InputStream in = new BufferedInputStream(new FileInputStream(localSrc)); Configuration config = new Configuration();
FileSystem fs = FileSystem.get(URI.create(dst),config); OutputStream out = fs.create(new Path(dst),new Progressable() { @Override
public void progress() {
System.out.println(".");
}
}); IOUtils.copyBytes(in, out, 4096, true);
}
}

  hadoop中执行:

Hadoop将本地文件复制到Hadoop文件系统

上一篇:Visual Studio 2013中因SignalR的Browser Link引起的Javascript错误一则


下一篇:android shape 怎么在底部画横线