getting an IFile [message #325203] |
Tue, 12 February 2008 10:06  |
Eclipse User |
|
|
|
Originally posted by: alexjaquet.gmail.com
Hi,
I would like to know what's wrong with my code (I'm attempting to read
the content of a file who's stored in one plug in directory)
Here is my code
private static final String RESOURCES_PATH =
" platform:/plugin/com.odcgroup.page.common/src/main/resources ";
private static final String FOOTER_FILE = RESOURCES_PATH + "/" +
"tableFooter.xml";
private void buildXspLogic(WidgetTransformerContext context, Widget
widget, Element parent) {
Element xspLogic = appendElement(context,parent,
XSPConstants.XSP_NAMESPACE_URI, XSPConstants.XSP_LOGIC);
StringBuffer condition = new StringBuffer();
IPath path = new Path(FOOTER_FILE);
IFile file
=ResourcesPlugin.getWorkspace().getRoot().getFileForLocation (path);
try {
InputStream inputStream = file.getContents();
char c;
while((c = (char) inputStream.read()) != -1) {
condition.append(c);
}
inputStream.close();
xspLogic.setTextContent(inputStream.toString());
}catch (Exception ex) {
Logger.error("Exception while reading the page footer file ",ex);
}
}
thanks in advance
Alexandre
|
|
|
|
|
|
Re: getting an IFile [message #325232 is a reply to message #325218] |
Tue, 12 February 2008 15:32  |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Hi,
you already have it. Your original note contained it:
private static final String RESOURCES_PATH =
" platform:/plugin/com.odcgroup.page.common/src/main/resources ";
private static final String FOOTER_FILE = RESOURCES_PATH + "/" +
"tableFooter.xml"
Alexandre Jaquet wrote:
> Rich Kulp a écrit :
>> Hi,
>>
>> IFile are only for resources in the workspace. A resource in a plugin
>> is not in the workspace, so you can't get an IFile for it.
>>
>> The best way to work with files in a plugin would be to create the URL
>> from the FOOTER_FILE string and just do openStream() against the URL.
>>
> Hi Rich,
>
> Thanks for your response but how can I get the path of the installed
> plug in ?
>
> Thanks
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.04086 seconds