1.读固定路径的properties文件

      Properties properties = new Properties();
        // 使用InPutStream流读取properties文件
        BufferedReader bufferedReader = new BufferedReader(new FileReader("E:/path.properties"));
        properties.load(bufferedReader);
        //获取key对应的value值
        String a =  properties.getProperty("sourcePath");
        System.out.println(a);

2.读相对路径的properties文件

Properties properties = new Properties();
        // 使用ClassLoader加载properties配置文件生成对应的输入流
        InputStream in = Main.class.getClassLoader().getResourceAsStream("resouces/path.properties");
        // 使用properties对象加载输入流
        properties.load(in);
                //获取key对应的value值
        String sourcePath = properties.getProperty("sourcePath");
        String path = properties.getProperty("path");