import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
public class PropertyTool {
private Properties property = new Properties();
public static PropertyTool getInstance(String fileName) {
PropertyTool temp = new PropertyTool();
if (!temp.load(new File(fileName)))
return null;
return temp;
}
private boolean load(File file) {
if (file == null)
return false;
if (!file.exists())
return false;
FileInputStream fin;
try {
fin = new FileInputStream(file);
property.load(fin);
} catch (Exception e) {
return false;
}
return true;
}
public String getProperty(String key) {
if (key == null)
return null;
return property.getProperty(key);
}
}
配置文件加载工具类
最新推荐文章于 2021-03-16 14:33:44 发布