code: public static File getFileFor(final URL anURL, final String encoding) {
  
          // Check sanity
          Validate.notNull(anURL, "anURL");
          Validate.notNull(encoding, "encoding");
  
          final String protocol = anURL.getProtocol();
          File toReturn = null;
          if ("file".equalsIgnoreCase(protocol)) {
              try {
                  final String decodedPath = URLDecoder.decode(anURL.getPath(), encoding);
                  toReturn = new File(decodedPath);
              } catch (Exception e) {
                  throw new IllegalArgumentException("Could not get the File for [" + anURL + "]", e);
              }
          } else if ("jar".equalsIgnoreCase(protocol)) {
  
              try {
  
                  // Decode the JAR
                  final String tmp = URLDecoder.decode(anURL.getFile(), encoding);
  
                  // JAR URLs generally contain layered protocols, such as:
                  // jar:file:/some/path/to/nazgul-tools-validation-aspect-4.0.2.jar!/the/package/ValidationAspect.class
                  final URL innerURL = new URL(tmp);
  
                  // We can handle File protocol URLs here.
                  if ("file".equalsIgnoreCase(innerURL.getProtocol())) {
  
                      // Peel off the inner protocol
                      final String innerUrlPath = innerURL.getPath();
                      final String filePath = innerUrlPath.contains("!")
                              ? innerUrlPath.substring(0, innerUrlPath.indexOf("!"))
                              : innerUrlPath;
                      toReturn = new File(URLDecoder.decode(filePath, encoding));
                  }
              } catch (Exception e) {
                  throw new IllegalArgumentException("Could not get the File for [" + anURL + "]", e);
              }
          }
  
          // All done.
          return toReturn;
      }
docs: Acquires the file for a supplied URL, provided that its protocol is is either a file or a jar.
  
  @param anURL    a non-null URL.
  @param encoding The encoding to be used by the URLDecoder to decode the path found.
  @return The File pointing to the supplied URL, for file or jar protocol URLs and null otherwise.