- package Hadoop.HDFS;
-
- 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 App2 {
- public static void main(String[] args) throws Exception {
- String locaSrc = "G://jf2.txt";
- String dst = "hdfs://hadoop/use/jf2.txt";
-
- InputStream in = new BufferedInputStream(new FileInputStream(locaSrc));
-
- 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.println("*");
- }});
-
- IOUtils.copyBytes(in, out, 4096, true);
- }
-
- }
复制代码
报错信息为: java.io.FileNotFoundException: G:/jf2.txt
请帮我看看,谢了。
|