希望有人能够提供帮助,我在java中比较新,并试图解决如何使用properties函数来读取多个属性值,而不一定按顺序或全部列表,然后将它们放入数组或字符串中,这样我就可以传递给另一个类来执行写入文件等“内容”。有可能有数百个属性值,只想挑选我想要的。 我可以得到一个像properties.getProperty(“ip”);并分配到一个字符串,但具有多个按照下面的问题...将多个java属性值读入字符串或数组
任何帮助将不胜感激。
Properties properties = new Properties();
try {
properties.load(new FileInputStream(args[0]));
}
catch (IOException e) {
System.out.println("Error - IOException - File not found...");
}
String model = properties.getProperty("model");
String codeLevel = properties.getProperty("codeLvl");
String[] dmdCommand = new String[properties.getProperty("ip")
+ properties.getProperty("rangeS")
+ properties.getProperty("rangeL")
+ properties.getProperty("PhyPG")
+ properties.getProperty("PhyLDEV")
+ properties.getProperty("PhyProc")
+ properties.getProperty("PhyExG")
+ properties.getProperty("PhyExLDEV")
+ properties.getProperty("PhyCMPK")];
如果您需要其他信息或数据样本,我们乐意提供。 欢呼声,并提前致谢:)
考虑使用https://docs.oracle.com/javase/7/docs/api/java/util/PropertyResourceBundle.html –