From: Fencer on
Hello, I have a class XPathTests that lives in the package tests_xpath.
In the same folder I also have an XML file, BIOMD0000000011.xml

Now I tried to get an URL to that file by doing the following:

URL url = XPathTests.classs.getResource("BIOMD0000000011.xml"); but null
is returned. I tried a few variants:
"/tests_xpath/BIOMD0000000011.xml"
"tests_xpath/BIOMD0000000011.xml"

but all return null. What is the correct way?

- Fencer
From: Fencer on
On 2010-07-28 01:29, Fencer wrote:
> Hello, I have a class XPathTests that lives in the package tests_xpath.
> In the same folder I also have an XML file, BIOMD0000000011.xml
>
> Now I tried to get an URL to that file by doing the following:
>
> URL url = XPathTests.classs.getResource("BIOMD0000000011.xml"); but null
> is returned. I tried a few variants:
> "/tests_xpath/BIOMD0000000011.xml"
> "tests_xpath/BIOMD0000000011.xml"
>
> but all return null. What is the correct way?
>
> - Fencer

Nevermind, I refreshed the project and the path
"/tests_xpath/BIOMD0000000011.xml" worked.

- Fencer
From: Roedy Green on
On Wed, 28 Jul 2010 01:32:55 +0200, Fencer
<no.i.dont(a)want.mail.from.spammers.com> wrote, quoted or indirectly
quoted someone who said :

>
>Nevermind, I refreshed the project and the path
>"/tests_xpath/BIOMD0000000011.xml" worked.

To answer that question, you need to know the name of the resource in
your jar. You can view the jar with JarLook or Winzip.
see http://mindprod.com/products1.html#JARLOOK
--
Roedy Green Canadian Mind Products
http://mindprod.com

You encapsulate not just to save typing, but more importantly, to make it easy and safe to change the code later, since you then need change the logic in only one place. Without it, you might fail to change the logic in all the places it occurs.
From: Arne Vajhøj on
On 29-07-2010 18:51, Roedy Green wrote:
> On Wed, 28 Jul 2010 01:32:55 +0200, Fencer
> <no.i.dont(a)want.mail.from.spammers.com> wrote, quoted or indirectly
> quoted someone who said :
>> Nevermind, I refreshed the project and the path
>> "/tests_xpath/BIOMD0000000011.xml" worked.
>
> To answer that question, you need to know the name of the resource in
> your jar. You can view the jar with JarLook or Winzip.
> see http://mindprod.com/products1.html#JARLOOK

When the problem is solved, then he don't need to do
anything to answer the no longer existing question.

Arne