On Wed, 12 Oct 2005 22:55:49 +0100, i_lk <> wrote:
> hi
> i m using JBuilderX... the problem i m facing is very basic yet i
> could'nt find the sol...i m retrieving the contents of an xml file
> using
>
>
> InputStream is = another_class.getResourceInputStream("xyz.XML");
>
>
> In another_class:-
>
>
> protected static InputStream getResourceInputStream(String xml_file)
> throws IOException {
> System.out.println(xml_file) ;
> ClassLoader cl = ResourceManager.class.getClassLoader();
> return cl.getResourceAsStream(xml_file);
> }
>
> the code is fine but it cant get the xyz.xml file..and it returns
> NULL.
>
> i have used every option... i want to keep the file in a separate
> directory in project files say dir1 .... what should i give in the
> path(as an argument)... how can i get the path of that file as a part
> of my
> program...?
>
> Thanks a lot
>
I can see that, as you say, the code is fine, except it's not working...
If the resource is on the classpath, you'll want to think about prefixing
the filename with a '/'. If, however, it's in a file outside the
classpath, as you indicate toward the end of your message, then have a
look at
http://java.sun.com/j2se/1.5.0/docs/...putStream.html
instead.
You might want to consider renaming that 'another_class' before anyone
else notices it, too
--
Ross Bamford -