code: public static File toFile(final URL url) {
          if (url.getProtocol().equals("file") == false) {
              throw new IllegalArgumentException("URL could not be converted to a File: " + url);
          }
  
          return new File(decodeUrl(url.getFile().replace('/', File.separatorChar)));
      }
docs: Convert from a <code>URL</code> to a <code>File</code>.
  <p>
  From version 1.1 this method will decode the URL.
  Syntax such as <code>file:///my%20docs/file.txt</code> will be
  correctly decoded to <code>/my docs/file.txt</code>. Starting with version
  1.5, this method uses UTF-8 to decode percent-encoded octets to characters.
  Additionally, malformed percent-encoded octets are handled leniently by
  passing them through literally.
  
  @param url  the file URL to convert, {@code null} returns {@code null}
  @return the equivalent <code>File</code> object if the URL's protocol is not <code>file</code>
  @throws NullPointerException if the parameter is null