code: public static File getResourceAsFile(String name)
    {
      URL resourceURL = getResource(name);
      if(resourceURL == null) {
        throw new NoSuchBeingException("Resource |%s| not found.", name);
      }
      String protocol = resourceURL.getProtocol();
      if("file".equals(protocol)) try {
        return new File(resourceURL.toURI());
      }
      catch(URISyntaxException e) {
        throw new BugError("Invalid syntax on URL returned by getResource.");
      }
      throw new UnsupportedOperationException("Can't get a file for a resource using protocol" + protocol);
    }
docs: Get file resource, that is, resource with <em>file</em> protocol. Try to load resource throwing exception if not
  found. If resource protocol is <em>file</em> returns it as {@link java.io.File} otherwise throws unsupported
  operation.
  
  @param name resource name.
  @return resource file.
  @throws NoSuchBeingException if named resource can't be loaded.
  @throws UnsupportedOperationException if named resource protocol is not <em>file</em>.