Tuesday, January 8, 2013

Reading resources from a Eclipse plugin


Project structure:









How do you get the path for services.xml file while you working in plug-in development  ?

String file = "services/services.xml"; //$NON-NLS-1$
String pluginlocation;
try {
Bundle bundle = Platform.getBundle("com.kk"); //my class pkg
URL pLocationUrl = FileLocator.find(bundle, new Path("/"), null);
URL pFileUrl = FileLocator.toFileURL(pLocationUrl);
pluginlocation = pFileUrl.getFile();
} catch (IOException e) {
//log error
}


String completePath = pluginlocation.append(File.separator).append(file);

No comments:

Post a Comment