关于使用java api上传文件。 在定义一个FileSystem变量的时候伪分布式和单机版的方法是不一样的,单机版使用的是FileSystem类的静态函数

FileSystem hdfs = FileSystem.get(conf)

伪分布式下需要使用Path来获得

Path dstDir = new Path("hdfs://localhost:9000/home/hadoop/hadoop");  
FileSystem hdfs = dstDir.getFileSystem(getConf());

不然的话会出现如下错误

Wrong FS: hdfs://localhost:9000/home/hadoop/hadoop, expected: file:///

相关文章:

  • 2021-12-09
  • 2021-09-07
  • 2021-12-05
  • 2021-10-01
  • 2021-09-28
  • 2021-08-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案