posted 4 years ago
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").