code: public static File getResourceAsFile(Class<?> clazz, String fn) throws IOException {
      URL url = clazz.getResource(fn);
      if (url == null || url.getFile() == null) {
        throw new IOException("resource \"" + fn + "\" relative to " + clazz + " not found.");
      }
      return new File(url.getFile());
    }
docs: Get a file to read the raw contents of the given resource :)