• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Files path

 
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have project structure like



I try to access like this but it doesn´t find the file



But if I try



It works. I want something like



Any idea, please?

Thanks



 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, you can't use packageName.packagerResources.file.data when referring to an external resource or File because the . is not a path separator in any system. The best you can do is packageName/packageResoures/file.data because the forward slash is a recognized path separator. You can also use the ClassLoader.getResource() with that type of path to get a URL to the data (which you may be able to turn into a File) or you could use ClassLoader.getResourceAsStream() to get it directly as an InputStream if what you want to do is read from it. You can even shorten the thing if you are in the packageName.file.class by using getClass().getResourceAsStream("packageResource/file.data").
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using packageName/packageResoures/file.data

Error the system can´´t find the path

It seems correct to me

Any idea, please?


Thanks
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show the code that uses that line, check spelling, remember that the path is case sensitive (even if the underlying OS is not (for example in Windows pacakageName is the same as PACKagename, but in Java they aren't the same).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic