private InputStream getStream(String imageKey, String path) throws CoreException { URL url = FileLocator.find(getBundle(imageKey), new Path(path), null); if (url != null) { try { return url.openStream(); } catch (IOException e) { throw new CoreException( new Status( IStatus.ERROR, OSGiUtil.getBundleName(getClass()), "Unable to open stream to URL '" + url + "'")); } } throw new CoreException( new Status( IStatus.ERROR, OSGiUtil.getBundleName(getClass()), "The path '" + path + "' is unknown.")); }
public final InputStream getImageData(String imageKey) throws CoreException { Map<String, String> map = getImageMap(); if (map.containsKey(imageKey)) { return getStream(imageKey, map.get(imageKey)); } throw new CoreException( new Status( IStatus.ERROR, OSGiUtil.getBundleName(getClass()), "The image key '" + imageKey + "' is unknown.")); }