URISyntaxException

Exception in thread “main” java.net.URISyntaxException: Illegal character in opaque part at index 2: D:\input\out1


文章目录

  • Exception in thread "main" java.net.URISyntaxException: Illegal character in opaque part at index 2: D:\input\out1
    • 1. 问题描述
    • 2. 代码
    • 3. 解决


1. 问题描述

Exception in thread “main” java.net.URISyntaxException: Illegal character in opaque part at index 2: D:\BaiduNetdiskDownload\input\out1
在这里插入图片描述


2. 代码

(已经更改正确)

//设置输入输出路径
private final static String File_In_Path = "file:///D:/BaiduNetdiskDownload/input/in1";
private final static String File_Out_Path = "file:///D:/BaiduNetdiskDownload/input/out1";

public static void main(String[] args) throws Exception {
    //Hadoop的安装路径
    System.setProperty("hadoop.home.dir","D:\\hadoop-2.6.1");
    Configuration conf = new Configuration();

    //删除已存在的输出文件
    FileSystem fileSystem = FileSystem.get(new URI(File_Out_Path),conf);
    if (fileSystem.exists(new Path(File_Out_Path))){
        fileSystem.delete(new Path(File_Out_Path),true);
    }

    Job job = Job.getInstance();
    job.setMapperClass(MyMapper.class);
    job.setJarByClass(ReduceJoin.class);
    job.setReducerClass(MyReduce.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    FileInputFormat.setInputPaths(job,new Path(File_In_Path));
    FileOutputFormat.setOutputPath(job,new Path(File_Out_Path));

    job.waitForCompletion(true);
}

3. 解决

注意这个路径
原始的错误
应该更改为:
在这里插入图片描述因为代码FileSystem fileSystem = FileSystem.get(new URI(File_Out_Path),conf);中使用的是Java的URI。(至于URI是什么请看 ->文章 URI 和 URL 的区别 <- )


--->有问题请联系QQ1436281495^_^

你可能感兴趣的:(大数据阶段,--------MR过程)