Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getResource(fileName)

 
sopal Pal
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In my program I am making a call as

ClassLoader.getSystemClassLoader().getResource(fileName)


If I try the above method with the filename as
viewing.proprties and that file resides in

c:\program files\

Then

This is the error I get :

------- Error ----------

url = file:/C:/Program%20Files/viewing.properties
java.io.FileNotFoundException: C:\Program%20Files\viewing.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at TestFile.getProperties(TestFile.java:79)
at TestFile.main(TestFile.java:19)

--------------------------


** ANY IDEA How to resolve this

The code works fine - if there is no SPACE in the directory.
Is there a way to get around this issue

Thanks
 
Norm Radder
Ranch Hand
Posts: 732
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your error example shows %20 in the path to the file. Replace that with a space. How do you get the path?

See the URLDecoder class(?) for a method to remove it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic