“;错误的FS…;预期:文件://”;在Java中尝试从HDFS复制FromLocalFile时

“;错误的FS…;预期:文件://”;在Java中尝试从HDFS复制FromLocalFile时,java,hadoop,hdfs,hadoop2,Java,Hadoop,Hdfs,Hadoop2,我正在尝试将abc.json从port/example\u File/2017复制到HDFS中的另一个位置/port/example\u File/2018, 按以下代码 String exampleFile= "hdfs://port/example_File/2017/abc.json" String targetFile="hdfs://port/example_File/2018" hdfs.copyFromLocalFile(new Path(exampleFile),new Path

我正在尝试将abc.jsonport/example\u File/2017复制到HDFS中的另一个位置/port/example\u File/2018, 按以下代码

String 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: Wrong FS:
 hdfs://port/example_File/2017/abc.json, expected: file:///
如何在HDFS中将文件从一个位置复制到另一个位置


谢谢,

copyFromLocal
是将文件从本地文件系统复制到HDFS

要复制HDFS群集中的文件,请为
srcFS
dstFs
使用并指定相同的文件系统


在HDFS群集内或两个不同HDFS群集之间复制大量文件时使用。请参阅DistCp Java API。

以下链接是否可以帮助您。。。请查收。这与我的情况不同,我无法将fs.default.name设置为所需的值hdfs://host:port,因为我将在许多服务器中部署。另外,我正在用这个@jbhanushali复制许多文件,我尝试了FileUtil.copy(新文件(f.getPath().toString())、hdfs、新路径(target_filepath)、false、conf);但我得到了org.jboss.resteasy.spi.UnhandledException:java.io.IOException:hdfs:/port/example_File/2017/abc.json实际上它不应该以这样的文件或目录开头hdfs://port/ 当我打印f.getPath().toString()时,它给出了相同的结果。但是,当它试图复制时,它将作为hdfs:/port使用,这有什么原因吗@franklinsijo@Ganesh同时传递源文件系统并省略URI。只需传递src路径的
/example\u File/2017/abc.json
。比如
FileUtil.copy(hdfs,新路径(“/example\u File/2017/abc.json”)、hdfs,新路径(target\u filepath)、false、conf