aspose file tools*
The moose likes Java in General and the fly likes Files path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Files path" Watch "Files path" New topic
Author

Files path

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 389
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



Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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").


Steve
Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 389
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Files path