public class TestResourceBundle { private static ResourceBundle resourceBundle = ResourceBundle
.getBundle("test"); public static void testGetStringArray() {
String[] values = resourceBundle.getStringArray("propertyS");
for(int i = 0; i < values.length; i++){
System.out.println(values[i]);
}
} public static void main(String[] args) {
testGetStringArray();
}
}test.properties如下:
===============================
key=value1
propertyS=a
propertyS=b
propertyS=c
==============================
resourceBundle.getStringArray()的用法是不是我理解出错了,帮忙指正一下,谢谢!
.getBundle("test"); public static void testGetStringArray() {
String[] values = resourceBundle.getStringArray("propertyS");
for(int i = 0; i < values.length; i++){
System.out.println(values[i]);
}
} public static void main(String[] args) {
testGetStringArray();
}
}test.properties如下:
===============================
key=value1
propertyS=a
propertyS=b
propertyS=c
==============================
resourceBundle.getStringArray()的用法是不是我理解出错了,帮忙指正一下,谢谢!
读取Properties类型文件可以使用java.util.Properties来进行读取
public static void readProperties(String filePath) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream (new FileInputStream(filePath));
props.load(in);
Enumeration en = props.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String Property = props.getProperty (key);
System.out.println(key+Property);
}
} catch (Exception e) {
e.printStackTrace();
}
}