1
我试图让一个文件在我的包带:如何处理URL协议包://
File file = new File(bundleContext.getBundle().
getResource("image/logo.jpg").toURI());
的结果与原因的抛出:IllegalArgumentException“URI方案不是‘文件’
。这是合乎逻辑的,但我应该如何打开一个文件,这个URL(包://28/image/logo.jpg)?
如果我用普通的ClassLoader我得到同样的结果
。 编辑:
我的解决方案:
URL url = this.getClass().getClassLoader().getResource("image/logo.jpg");
InputStream in = new BufferedInputstream(url.openStream());
这对我很有用。 – 2013-03-20 15:42:02