50,530
社区成员
发帖
与我相关
我的任务
分享
new BufferReader(new InputStreamReader(new ByteArrayInputStream(...)));
import org.apache.log4j.Logger;
public class PropertyUtil {
/**
* @param args
*/
public static void main(String[] args) {
PropertyUtil test01 = new PropertyUtil();
System.out.println(test01.getProperty("libowifi"));
}
/*
* 获取属性文件的值
*/
private static final Logger logger = Logger.getLogger(PropertyUtil.class);
private static Properties properties;
static {
// 加载属性文件
try {
InputStream inputStream = PropertyUtil.class.getClassLoader().getResourceAsStream("haixi.properties");
try {
properties=new Properties();
properties.load(inputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
inputStream.close();
}
} catch (Exception e) {
logger.error(e.getMessage());
}
}
public static String getProperty(String key) {
return properties.getProperty(key);
}
}