我想将hdfs复制文件的功能重新写入本地
String src = args[0]; // hdfs
String dst = args[1]; // local path
/*
* Prepare the input and output filesystems
*/
Configuration conf = new Configuration();
FileSystem inFS = FileSystem.get(URI.create(src), conf);
FileSystem outFS = FileSystem.get(URI.create(dst), conf);
/*
* Prepare the input and output streams
*/
FSDataInputStream in = null;
FSDataOutputStream out = null;
// TODO: Your implementation goes here...
in = inFS.open(new Path(src));
out = outFS.create(new Path(dst),
new Progressable() {
/*
* Print a dot whenever 64 KB of data has been written to
* the datanode pipeline.
*/
public void progress() {
System.out.print(".");
}
});
(1)当我设置当前导演的本地路径时
-> JAVA I/O error. mkdirs failed to create file
(2)当我将路径设置为不存在的文件夹时
->创建一个新文件夹,并且我的复制文件位于其中。
我该怎么办?
我相信我不应该使用filesystem.create()?,对吗?
编辑
一个相关的文件系统库链接: https://hadoop.apache.org/docs/current/api/org/apache/hadoop/fs/FileSystem.html#create(org.apache.hadoop.fs.Path)