Hadoop关于Wrong FS错误

关于使用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:///

原文地址:https://www.cnblogs.com/jirimutu01/p/4106536.html