利用java.util.Properties读取ini配置文件
转载自: http://www.hijava.org/j2se/util-properties-ini
[code] public void getOption() {
String OptionFile = "Option.ini";
Properties p = new Properties();
try {
p.load(new FileInputStream(OptionFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String Thread_num = p.getProperty("thread_num");
String Pass_num = p.getProperty("pass_num");
String Interval_time = p.getProperty("interval_time");
}[/code]
Option.ini文件内容:
[code][option]
thread_num=2
pass_num=6
interval_time=6000[/code]