“尝试从Java HDFS中的CopyFromLocalFile文件中错误的FS ... expected:file:///” [英] “Wrong FS… expected: file:///” when trying to copyFromLocalFile from HDFS in Java
问题描述
我试图将 abc.json 从 port / example_File / 2017 复制到HDFS中的另一个位置 / port / example_File / 2018
by below code
字符串exampleFile =hdfs://port/example_File/2017/abc.json
String targetFile =hdfs:// port / example_File / 2018
hdfs.copyFromLocalFile(new Path(exampleFile),new Path(targetFile))
我得到的是异常
org.jboss.resteasy .spi.UnhandledException:
java.lang.IllegalArgumentException:错误的FS:
hdfs://port/example_File/2017/abc.json,预计:file:///
如何在HDFS中将文件从一个位置复制到另一个位置
要在HDFS集群中复制文件,请使用 FileUtil.copy()
并指定相同的文件系统对于 srcFS
和 dstFs
。
使用 DistCp
在HDFS群集内或两个不同的HDFS群集之间复制大量文件时。请参阅DistCp Java API 此处。
I am trying to copy abc.json from port/example_File/2017 to another location /port/example_File/2018 in HDFS, by below code
String exampleFile= "hdfs://port/example_File/2017/abc.json"
String targetFile="hdfs://port/example_File/2018"
hdfs.copyFromLocalFile(new Path(exampleFile),new Path(targetFile))
I am getting below exception
org.jboss.resteasy.spi.UnhandledException:
java.lang.IllegalArgumentException: Wrong FS:
hdfs://port/example_File/2017/abc.json, expected: file:///
How to copy file from one location to another in HDFS
Thanks,
copyFromLocal
is to copy files from Local Filesystem to HDFS.
To copy files within an HDFS cluster, use FileUtil.copy()
and specify same Filesystem for both srcFS
and dstFs
.
Use DistCp
when copying large number of files within a HDFS cluster or between two different HDFS clusters. Refer DistCp Java API here.
这篇关于“尝试从Java HDFS中的CopyFromLocalFile文件中错误的FS ... expected:file:///”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!