I am writing an Eclipse plugin where I want to read a file within the project and do something on it.
For example the file is located under : Project testplugin and path : com/flow/FlowMain.java
I want to programmatically read this file and add some code in it.
What I trying is :
String base = Platform.getBundle(config.getPluginId()).getEntry(“/”).toString();
String relativeUri = “com/flow/FlowMain.java”;
File f = new File(base+relativeUri);
This obviously fails because the value of “base+relativeUri” returns :
entry://1079.fwk5184781/com/flow/FlowMain.java
So how do I go about getting the complete file path from within the plugin ?
‘entry’ is a protocol defined by equinox, so you can get the real path using org.eclipse.core.runtime.FileLocator.toFileURL(URL).