读取properties配置文件方法

来源:互联网 发布:知茵女装网上专卖店 编辑:程序博客网 时间:2024/05/15 01:41

private static Properties properties = new Properties();
private static String path = System.getProperty("user.dir").replace("\\", "/") + "/avenuebus.properties";

public static void getIP(){

FileInputStream s = null;
try {   
System.out.println(path);
s = new FileInputStream(new File(path));   
properties.load(s);
IP = properties.getProperty("avenuebus.IP");
} catch (Exception e) {   
e.printStackTrace();
} finally {
try {
if (s != null) {
s.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}

}

avenuebus.properties配置文件名称

avenueBus.IP=168.0.0.1//配置IP

0 0