读 properties
程序员文章站
2022-07-13 21:34:09
...
public class PropUtil { private static String getKey(String key){ Properties properties = new Properties(); InputStream inputStream = PropUtil.class.getClassLoader().getResourceAsStream("system.properties"); System.out.println(inputStream); try { properties.load(inputStream); } catch (IOException e) { e.printStackTrace(); } String value = properties.getProperty(key); return value; } public static void main(String[] args) { // System.out.println(getKey("appServerIp")); ResourceBundle resource = ResourceBundle.getBundle("system"); System.out.println(resource.getString("appServerIp")); } }
https://blog.csdn.net/mhmyqn/article/details/7683909