Exception in thread "main" java.lang.IllegalArgumentException:解决方法

时间:2021-03-25 10:59:38

使用fileSystem的delete方法无法删除文件或目录

Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://h1:9000/out, expected: file:///

at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:381)

at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:55)

at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:393)

at org.apache.hadoop.fs.ChecksumFileSystem.delete(ChecksumFileSystem.java:452)

at mapreduce.WordCountApp.main(WordCountApp.java:36)

由于获取fileSystem对象的时候没有传入访问地址导致。

FileSystem fileSystem = FileSystem.get(new URI(INPUT_PATH),conf);