Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a file using a relative Path

 
Carlos Duque
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to load a file like this:


But url1 is always "null". I have to use .getResource() because everything will be in a single jar file, the structure of the project is :



and the output from System.out.println("user.dir") is: D:\proyectos\workspace\nb\userver

Any Ideas on what I'm doing Wrong?
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Carlos Duque:
I have to use .getResource() because everything will be in a single jar file


Is everything currently jar'ed up? If not, you will have to put userver/src on the classpath for the classloader to find resources/student-records-digester-rules.xml.
 
Carlos Duque
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe,

I managed to solve it, and then got into another problem with an inputStream:



I got it working too and the code ended up being:



However, I don't understand why


doesn't need a "/" at the beginnig of the Path to the file but this line:



Does need the "/". Sorry, but couldn't find anything on the documentation that discussed this so I thought I could ask here if anyone knows the reason behind this difference.

Regards,

[ June 07, 2007: Message edited by: Carlos Duque ]

[ June 07, 2007: Message edited by: Carlos Duque ]
[ June 07, 2007: Message edited by: Carlos Duque ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!