If you really need a file, and you know that the resource is not inside the bank or downloaded remotely, then you can use getResource.
URL resourceLocation = Object.class.getResource(resourcePath);
if (resourceLocation == null) { throw new FileNotFoundException(resourcePath); }
File myFile = new File(resourceLocation.toURI());
If you do not need absolutely FileChannelor cannot make assumptions about how your class path is laid out, then Andy Thomas-Cramer's decision is probably the best.
source
share