Search code examples
eclipseeclipse-pluginrcpeclipse-jdt

How to get folder from OSGI bundle?


I have own OSGI bundle that have folder inside with some resources. How to read that folder from bundle and get all children of it?

I used before following code.:

    Bundle bundle = Platform.getBundle(bundleID);
    URL fileURL = bundle.getEntry(templatePath);
    URL url = FileLocator.resolve(fileURL);

This code workd utils I exported Eclipse application as Eclipse product.

But I have URL is not hierachical excepiton.


Solution

  • You can use the findEntries method on Bundle to locate files in the bundle and any attached fragments:

    Bundle bundle = Platform.getBundle(bundleID);
    Enumeration<URL> urls = bundle.findEntries("/folder", "*", false);