Servlet读取配置文件--非servlet下

public class TestDao {

    public void update() throws IOException {
        String url = TestDao.class.getClassLoader()
                .getResource("cn/linson/dao/db.properties").getPath();
        System.out.println(url);
        FileInputStream fis = new FileInputStream(url);
        Properties pro = new Properties();
        pro.load(fis);
        System.out.println(pro.getProperty("name"));
    }

}

 

posted @ 2014-04-14 22:18  一路向北中  阅读(157)  评论(0)    收藏  举报