private String fileName = "/weather.properties";//文件路径
Properties p = new Properties();
InputStream in = WeatherBo.class.getResourceAsStream(fileName);
p.load(in);
in.close();
String url=p.getProperty("SUZHOU"); //通过属性名获取对应的属性值
本文详细介绍了如何使用Java的Properties类从属性文件中获取指定位置的配置信息,并通过实例展示了具体操作过程。
private String fileName = "/weather.properties";//文件路径
Properties p = new Properties();
InputStream in = WeatherBo.class.getResourceAsStream(fileName);
p.load(in);
in.close();
String url=p.getProperty("SUZHOU"); //通过属性名获取对应的属性值

被折叠的 条评论
为什么被折叠?