Friday, June 8, 2007

Absolute path to plugin's resource

We want the absolute path to "demo/test.txt" in our plugin with id "com.example.plugin"

code

String pluginId = "com.example.plugin";
String pluginRelativePath = "demo/test.txt";
Bundle bundle = Platform.getBundle(pluginId);
URL url = bundle.getEntry(pluginRelativePath);
URL resolvedUrl = null;
try {
resolvedUrl = FileLocator.resolve(url);
} catch (IOException e) {
// TODO: handle exception
}

1 comment:

skolima said...

Only on Windows this creates a path beginning with / (e.g. "/C:/Program Files").