JAVA 读取配置文件properties

//读取配置文件获取name
        InputStream inputStream = new FileInputStream("config.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
     String name = properties.getProperty("name")
 

新建一个配置文件:config.properties,放在项目得根目录,如果放在其他位置则会出现“系统找不到文件”错误。

 

posted @ 2022-08-06 17:40  湘summer  阅读(243)  评论(0)    收藏  举报