code: public static File getFile(String resourceOrFile, Class<?> cls,
              boolean deleteTmpOnExit) throws FileNotFoundException {
          try {
  
              // jar:file:/home/.../blue.jar!/path/to/file.xml
              URI uri = getURL(resourceOrFile, cls).toURI();
              String uriStr = uri.toString();
              if (uriStr.startsWith("jar")) {
  
                  if (uriStr.endsWith("/")) {
                      throw new UnsupportedOperationException(
                              "cannot unjar directories, only files");
                  }
  
                  String jarPath = uriStr.substring(4, uriStr.indexOf("!"))
                          .replace("file:", "");
                  String filePath = uriStr.substring(uriStr.indexOf("!") + 2);
  
                  JarFile jarFile = new JarFile(jarPath);
                  assert (jarFile.size() > 0) : "no jarFile at " + jarPath;
  
                  Enumeration<JarEntry> entries = jarFile.entries();
  
                  while (entries.hasMoreElements()) {
  
                      JarEntry jarEntry = entries.nextElement();
                      if (jarEntry.toString().equals(filePath)) {
                          InputStream input = jarFile.getInputStream(jarEntry);
                          assert (input != null) : "empty is for " + jarEntry;
                          return tmpFileFromStream(input, filePath,
                                  deleteTmpOnExit);
                      }
                  }
                  assert (false) : "file" + filePath + " not found in " + jarPath;
                  return null;
              } else {
                  return new File(uri);
              }
  
          } catch (URISyntaxException e) {
              throw new FileNotFoundException(resourceOrFile);
          } catch (IOException e) {
              throw new FileNotFoundException(resourceOrFile);
          }
      }
docs: Use getInputStream instead, because Files are trouble, when in (maven)
  JARs