• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Reading a file using a relative Path

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic