论坛首页 入门讨论版 J2ME

两种方式加载log4j资源文件

浏览 144 次
该帖已经被评为新手帖
作者 正文
最后更新时间:2008-06-29
方法一:
Properties prop = new Properties();
File f = new File("绝对路径");
FileInputStream is = null;

try {
is = new FileInputStream(f);
prop.load(is);
PropertyConfigurator.configure(prop);
} catch (FileNotFoundException e) {
e.printStackTrace();
}

方法二:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
is = cl.getResourceAsStream("config/Log4j.properties");
Properties prop = new Properties();
prop.load(is);
PropertyConfigurator.configure(prop);
   
论坛首页 入门讨论版 J2ME

跳转论坛:
JavaEye推荐