バンドル内のファイルを次のように取得しようとしています:
File file = new File(bundleContext.getBundle().
getResource("image/logo.jpg").toURI());
結果は、「URIスキームが「ファイル」ではない」という原因のIllegalArgumentExceptionです。
これは論理的ですが、このURL(bundle://28/image/logo.jpg)でファイルを開くにはどうすればよいですか?
通常のClassLoaderを使用すると、同じ結果が得られます。
編集:
私の解決策:
URL url = this.getClass().getClassLoader().getResource("image/logo.jpg");
InputStream in = new BufferedInputstream(url.openStream());