IT Life

如何使用jar文件当中的资料

利用this.getClass().getClassLoader().getResource(string)
取得资料,开启stream。

						
								public
						
						
								class
						 ReadInnerFile {public ReadInnerFile() throws IOException {
        URL u = this.getClass().getClassLoader().getResource("xd.xml");
        BufferedReader br = new BufferedReader(new InputStreamReader(u
                .openStream()));
        String line = "";
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        br.close();
 
    }publicstaticvoid main(String[] args) throws IOException {new ReadInnerFile();
    }}

posted on 2006-07-28 22:43 tony-dl 阅读(218) 评论(0)  编辑  收藏 所属分类: J2se->jar


只有注册用户登录后才能发表评论。


网站导航: