gpt4 book ai didi

java - 在 Java 中尝试从 HDFS 复制 FromLocalFile 时出现 “Wrong FS… expected: file:///”

转载 作者:可可西里 更新时间:2023-11-01 15:27:06 33 4
gpt4 key购买 nike

我正在尝试将 abc.jsonport/example_File/2017 复制到 HDFS 中的另一个位置 /port/example_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 集群中复制文件,请使用 FileUtil.copy()并为 srcFSdstFs 指定相同的文件系统。

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

关于java - 在 Java 中尝试从 HDFS 复制 FromLocalFile 时出现 “Wrong FS… expected: file:///”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43155247/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com