【问题标题】:The method listFiles(Path, boolean) is undefined for the type FileSystem未为 FileSystem 类型定义方法 listFiles(Path, boolean)
【发布时间】:2016-11-30 19:24:08
【问题描述】:

我正在获取 FileSystem 类型的方法 listFiles(Path, boolean) 未定义。有人遇到过这个问题吗?

Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
RemoteIterator<LocatedFileStatus> itr =  fs.listFiles(srcPath,true);

【问题讨论】:

  • 确保你有正确的导入。
  • FileSystem 中好像没有 listFiles。

标签: java hadoop filesystems fs


【解决方案1】:

您可能正在导入 java 文件系统,而不是 Apache 文件系统。检查您的导入。

【讨论】:

  • 这是我的导入。 import java.io.IOException;import java.util.ArrayList;import java.util.List;`import org.apache.hadoop.conf.Configuration;' '导入 org.apache.hadoop.fs.FileStatus;' '导入 org.apache.hadoop.fs.FileSystem;' '导入 org.apache.hadoop.fs.LocatedFileStatus;' '导入 org.apache.hadoop.fs.Path;' '导入 org.apache.hadoop.fs.RemoteIterator;'
  • 嗯,看起来不错。我想知道您的图书馆是否有问题。您使用的是哪个 IDE?当你输入“fs.”时,自动完成列出了哪些方法?
  • 可能存在依赖冲突。我重新创建了项目,它可以工作...谢谢...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-07
  • 2020-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多