“Wrong FS… expected: file:///” when trying to read file from HDFS in Java

前端 未结 2 1499
情话喂你
情话喂你 2021-01-18 00:55

I am unable to read a file from HDFS using Java:

String hdfsUrl = \"hdfs://:\";
Configuration configuration = new Configuration();
conf         


        
2条回答
  •  温柔的废话
    2021-01-18 01:08

    Try this:

    Configuration configuration = new Configuration();
    FileSystem fs = FileSystem.get(new URI(), configuration);
    Path filePath = new Path();
    FSDataInputStream fsDataInputStream = fs.open(filePath);
    BufferedReader br = new BufferedReader(new InputStreamReader(fsDataInputStream));
    

    Please refer to http://techidiocy.com/java-lang-illegalargumentexception-wrong-fs-expected-file/

    A similar problem is addressed.

提交回复
热议问题