Properties proper = new Properties(); proper.load(new StringReader(config)); //把字符串转为reader Enumeration enum1 = proper.propertyNames(); while (enum1.hasMoreElements()) { String strKey = (String) enum1.nextElement(); String strValue = proper.getProperty(strKey); map.put(strKey, Integer.valueOf(strValue)); }
字符串示例 :
A=1
B=2
C=3
本文介绍了一种利用Java的Properties类来解析配置信息的方法。通过将配置字符串加载到Properties对象中,可以方便地遍历并获取所有配置项及其对应的值。示例代码展示了如何将这些值存入Map容器,便于后续的程序调用。
311

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



