在eclipse上运行如下java 代码如下:
Configuration conf = new Configuration();
FileSystem hdfs = FileSystem.get(conf);
Path inPath = new Path(path);
//
FSDataInputStream dis = hdfs.open(inPath);
出现如下异常:
Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://localhost:9000/user/hadoop/input/datas.txt:19000/user/hadoop/input/part-00000, expected: file:///
解决方案:
hadoop需要把集群上的core-site.xml和hdfs-site.xml放到当前工程下。eclipse工作目录的bin文件夹下面。
可能的原因是:
因为是访问远程的HDFS 需要通过URI来获得FileSystem.