Opening files in RAP project [message #82891] |
Mon, 14 April 2008 23:14 |
Eclipse User |
|
|
|
Originally posted by: tavoaqp.gmail.com
Hi everybody
Im having a very simple problem (I think) although I can't solve it
because of my lack of knowledge about Equinox.
I want to open an XML file in the start method of my plugin, how can I
do that? So far I have tried the following:
Bundle bundle=Platform.getBundle(MyPluginActivator.PLUGIN_ID);
URL found=bundle.getResource("testfile.xml");
InputStream fileinput=found.openStream();
but when I "fileInput" that to a SAXParser instance and try to load it,
the debugger shows this message:
java.lang.IllegalArgumentException: InputStream cannot be null
Any hints on this issue?
I will appreciate any help.
Best Regards
Gustavo
|
|
|
Re: Opening files in RAP project [message #82921 is a reply to message #82891] |
Tue, 15 April 2008 07:54 |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
here is a snippet of how i open xml files in my app:
is =
getClass().getClassLoader().getResourceAsStream("resources/templates/anschreiben_betrieb.xml ");
this method returns an inputstream which you can use to parse. the files
are located in <project folder>/resources/templates/
hth
-ben
|
|
|
Re: Opening files in RAP project [message #82951 is a reply to message #82891] |
Tue, 15 April 2008 08:22 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
where does the file reside in your bundle?
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Gustavo [mailto:tavoaqp@gmail.com]
Bereitgestellt: Dienstag, 15. April 2008 01:14
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Opening files in RAP project
Betreff: Opening files in RAP project
Hi everybody
Im having a very simple problem (I think) although I can't solve it
because of my lack of knowledge about Equinox.
I want to open an XML file in the start method of my plugin, how can I
do that? So far I have tried the following:
Bundle bundle=Platform.getBundle(MyPluginActivator.PLUGIN_ID);
URL found=bundle.getResource("testfile.xml");
InputStream fileinput=found.openStream();
but when I "fileInput" that to a SAXParser instance and try to load it,
the debugger shows this message:
java.lang.IllegalArgumentException: InputStream cannot be null
Any hints on this issue?
I will appreciate any help.
Best Regards
Gustavo
|
|
|
Re: Opening files in RAP project [message #83036 is a reply to message #82951] |
Tue, 15 April 2008 13:59 |
Eclipse User |
|
|
|
Originally posted by: tavoaqp.gmail.com
Hi Frank
I solved the issue with the following:
Bundle bundle=Platform.getBundle(AWActivator.PLUGIN_ID);
URL fileURL=BundleUtility.find(bundle, "testfile.xml");
fileURL.openStream();
FileInputStream br=(FileInputStream) fileURL.getContent();
it seems the stream needs to be opened first.
Thanks
Gustavo
Frank Appel wrote:
> Hi,
>
> where does the file reside in your bundle?
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Gustavo [mailto:tavoaqp@gmail.com]
> Bereitgestellt: Dienstag, 15. April 2008 01:14
> Bereitgestellt in: eclipse.technology.rap
> Unterhaltung: Opening files in RAP project
> Betreff: Opening files in RAP project
>
>
> Hi everybody
> Im having a very simple problem (I think) although I can't solve it
> because of my lack of knowledge about Equinox.
> I want to open an XML file in the start method of my plugin, how can I
> do that? So far I have tried the following:
>
> Bundle bundle=Platform.getBundle(MyPluginActivator.PLUGIN_ID);
> URL found=bundle.getResource("testfile.xml");
>
> InputStream fileinput=found.openStream();
>
> but when I "fileInput" that to a SAXParser instance and try to load it,
> the debugger shows this message:
>
> java.lang.IllegalArgumentException: InputStream cannot be null
>
> Any hints on this issue?
>
> I will appreciate any help.
>
> Best Regards
>
> Gustavo
>
|
|
|
Powered by
FUDForum. Page generated in 0.03437 seconds