To load a resource from a deployed package, you can do the following (the resource for loading must be included in your binary build.properties ):
Bundle bundle = YourBundleActivator.getDefault().getBundle(); IPath path = new Path("rules/setup.txt"); URL setupUrl = FileLocator.find(bundle, path, Collections.EMPTY_MAP); File setupFile = new File(FileLocator.toFileURL(setupUrl).toURI());
Please note that this is different from getting something from the workspace, because when your package is running, searching for something in the workspace refers to the workspace of the workspace, not the development workspace. If you want something from the runtime workspace, you can access it as follows:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resourceInRuntimeWorkspace = root.findMember("rules/setup.txt"); File file = new File(resourceInRuntimeWorkspace.getLocationURI());
source share