woyoudn 发表于 2016-12-12 07:09:59

hadoop上传本地文件到hdfs报错

public static void Copy() throws IOException{
Configuration cfg = new Configuration();
FileSystem hdfs = FileSystem.get(cfg);
//File file = new File("C:\\XXX\\API\\ss.txt");
Path src = new Path("C://XXX/API/ss.txt");
Path dst = new Path("/");
hdfs.copyFromLocalFile(src, dst);
System.out.println("uploud to "+ cfg.get("fs.default.name"));
FileStatus files[] = hdfs.listStatus(dst);
for(FileStatus file : files){
System.out.println(file.getPath());
}
}

当我执行上述代码的时候总是报拒绝访问ss.txt文件。不知什么原因。ss.txt可以在本地打开,能够用java的一般IO读写操作。希望哪位帮我看看什么问题。
页: [1]
查看完整版本: hadoop上传本地文件到hdfs报错