package cn.ac.iscas.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertiesUtil {
public static Properties prop = new Properties();
public static Object getProperty(String name) {
return prop.get(name);
}
/**
* 加载配置文件kjdj.properties
*/
public static void initProperties() {
String sateudp = System.getProperty("user.dir") + File.separator + "kjdj.properties";
try {
prop.load(new FileInputStream(new File(sateudp)));
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getString(String name) {
initProperties();
Object value = prop.get(name);
if (value != null) {
return value.toString();
}
return "";
}
public static int getInt(String name) {
initProperties();
Object value = prop.get(name);
if (value != null) {
return Integer.parseInt(value.toString());
}
return 0;
}
}
07-01
573
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
765
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-05