Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » getting an IFile
getting an IFile [message #325203] Tue, 12 February 2008 10:06 Go to next message
Eclipse UserFriend
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 #325209 is a reply to message #325203] Tue, 12 February 2008 10:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

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.

--
Thanks,
Rich Kulp
Re: getting an IFile [message #325218 is a reply to message #325209] Tue, 12 February 2008 10:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

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
Re: getting an IFile [message #325220 is a reply to message #325218] Tue, 12 February 2008 10:56 Go to previous messageGo to next message
Eclipse UserFriend
Why not Simply

Platform.getBundle("my.bundle.id").... . The given bundle has methods to
access the resurce.

Tom

Alexandre Jaquet schrieb:
> 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


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: getting an IFile [message #325232 is a reply to message #325218] Tue, 12 February 2008 15:32 Go to previous message
Eclipse UserFriend
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
Previous Topic:Import project automatically
Next Topic:Forms Text Wrap
Goto Forum:
  


Current Time: Sat Jul 19 14:37:38 EDT 2025

Powered by FUDForum. Page generated in 0.04619 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top