gpt4 book ai didi

Hadoop 文件系统删除源文件

转载 作者:可可西里 更新时间:2023-11-01 16:38:35 27 4
gpt4 key购买 nike

我使用以下方法将文件从本地 PC 上传到 hdfs:

FileSystem fs = FileSystem.get(conf);
boolean deleteSrc = true;
String destFile = "/user/admin/my.csv";
fs.copyFromLocalFile(deleteSrc,new Path(inputFile), new Path(destFile));

这会导致文件从本地存储中删除。所以,复制实际上是一个'移动'。
我如何只上传 loca 文件的副本?

最佳答案

请注意,您正在将 copyFromLocalFile 调用的第一个参数设置为 true,这会导致本地文件被删除。如果要保留本地文件,请将 deleteSrc 设置为 false

以下是copyFromLocalFile 方法的详细信息。

public void copyFromLocalFile(boolean delSrc,
boolean overwrite,
Path[] srcs,
Path dst)
throws IOException

The src files are on the local disk. Add it to the filesystem at the given dst name. delSrc indicates if the source should be removed

Parameters:

delSrc - whether to delete the src
overwrite - whether to overwrite an existing file
srcs - array of paths which are source
dst - path

Throws:

IOException - IO failure

您也可以引用this .

关于Hadoop 文件系统删除源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46512258/

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