Forums Register Login

Trouble getting to a file

+Pie Number of slices to send: Send
I have an xslt file that I need to read in. The directory structure looks like this:

NetbeansProjects
>CustomerService
>>build
>>>classes
>>>>customerservice
>>>>>MAIN CLASS IS HERE
>>>>>com
>>>>>>mycorp
>>>>>>>myservice
>>>>>>>>proxy
>>>>>>>>>customer
>>>>>>>>>>ALL THE CLASS FILES ARE HERE
>>>>>resources (note, same level as customerservice under classes)
>>>>>>myfile.xslt


I've tried using getResourceAsStream to no avail. What I have tried is:



When I run it I get this:

Could not find file: \myfile.xslt
Current locaiton is: C:\NetBeansProjects\CustomerService\.

What am I doing wrong?

+Pie Number of slices to send: Send
Got it.

Need to use:

URL url = Thread.currentThread().getContextClassLoader().getResource(DEFAULT_XSLT_FILE);

and also prefix the file with the root directory like this:

private static final String DEFAULT_XSLT_FILE = "resources/ClcsProxyRetrieveCustomerResponseFilter.xslt";
+Pie Number of slices to send: Send
Resources always work with /, so replace File.separator with that.
This one time, at bandcamp, I had relations with a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 680 times.
Similar Threads
OK to read the request body within a filter?
Dowloading a file from a a struts 2 web application
problem in reading a file.
url error ,please help
Help with Chat software
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:33:02.