提供的URL是否为Jar文件URL 判断依据为file协议且扩展名为.jar

@param url the URL to check
@return whether the URL has been identified as a JAR file URL
@since 4.1
761308
public static boolean isJarFileURL(URL url) {
		return (URL_PROTOCOL_FILE.equals(url.getProtocol()) && //
				url.getPath().toLowerCase().endsWith(FileUtil.JAR_FILE_EXT));
	}
365318
public static String fileNameForUrl( URL contentUrl )
  {
    String fileName = null;
    Matcher matcher = FILE_NAME_PATTERN.matcher(contentUrl.getPath());
    if( matcher.find() ) {
      fileName = matcher.group(1);
    }
    return fileName;
  }
1257989
public static void browse(String url) throws Exception {
        //获取操作系统的名字
        String osName = System.getProperty("os.name", "");
        if (osName.startsWith("Mac OS")) {
            //苹果的打开方式
            Class fileMgr = Class.forName("com.apple.eio.FileManager");
            Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[]{String.class});
            openURL.invoke(null, new Object[]{url});
        } else if (osName.startsWith("Windows")) {
            //windows的打开方式。
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
        } else {
            // Unix or Linux的打开方式
            String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"};
            String browser = null;
            for (int count = 0; count < browsers.length && browser == null; count++) {
                //执行代码，在brower有值后跳出，
                //这里是如果进程创建成功了，==0是表示正常结束。
                if (Runtime.getRuntime().exec(new String[]{"which", browsers[count]}).waitFor() == 0) {
                    browser = browsers[count];
                }
            }
            if (browser == null) {
                throw new Exception("Could not find web browser");
            } else {
                //这个值在上面已经成功的得到了一个进程。
                Runtime.getRuntime().exec(new String[]{browser, url});
            }
        }
    }
440993
private static URL fixURL(URL jarURL)
    {
        String jarURLString = jarURL.toExternalForm();
        if (StringUtils.contains(jarURLString, ' ')) {
            jarURLString = jarURLString.replace(" ", "%20");

            try {
                return new URL(jarURLString);
            } catch (MalformedURLException e) {
                // TODO: Log something ?
            }
        }

        return jarURL;
    }
1203766
private static boolean isJarURL(final URL rootDirResource) {

        final String protocol = rootDirResource.getProtocol();

        /**
         * Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip",
         * "wsjar" or "code-source".
         * <p>
         * "zip" and "wsjar" are used by BEA WebLogic Server and IBM WebSphere, respectively, but can be treated like
         * jar files. The same applies to "code-source" URLs on Oracle OC4J, provided that the path contains a jar
         * separator.
         * *
         */
        return "jar".equals(protocol) || "zip".equals(protocol) || "wsjar".equals(protocol)
                || ("code-source".equals(protocol) && rootDirResource.getPath().contains(JAR_URL_SEPARATOR));

    }
2840
private String extractPathFromUrl(String url) {
        String path = url.replaceAll(".+://.+?(?=/)", "");
        if (!path.startsWith("/")) {
            throw new RuntimeException("Path must start with '/': " + path);
        }
        return path;
    }
569302
@Override
	public URL getResourceUrl(String fileName) {
		if (fileName == null) {
			return null;
		}
		URL resource = getClass().getResource(fileName);
		if (resource == null) {
			resource = Thread.currentThread().getContextClassLoader().getResource(fileName);
			if (resource == null) {
				resource = ClassLoader.getSystemResource(fileName);
				if (resource == null) {
					File file = new File(fileName);
					if (file.exists()) {
						try {
							resource = file.toURI().toURL();
						} catch (MalformedURLException e) {
							throw new JKException(e);
						}
					}
				}
			}
		}
		return resource;
	}
969449
public static HttpUrl parse(String url) {
        Builder builder = new Builder();
        Builder.ParseResult result = builder.parse(null, url);
        return result == Builder.ParseResult.SUCCESS ? builder.build() : null;
    }
814319
static String getFilenameFromUrl(String url) {
    String filename = md5(url) + ".down";

    int index = url.lastIndexOf("/");
    if (index > 0) {
      String tmpFilename = url.substring(index + 1);
      int qmarkIndex = tmpFilename.indexOf("?");
      if (qmarkIndex > 0) {
        tmpFilename = tmpFilename.substring(0, qmarkIndex - 1);
      }

      /* if filename contains '.', then the filename has file extension */
      if (tmpFilename.contains(".")) {
        filename = tmpFilename;
      }
    }

    return filename;
  }
1148453
public T url(String url) {
        if (view!=null) {
            if (view instanceof WebView) {
                ((WebView)view).loadUrl(url);
            }
            if (view instanceof TextView) {
                ((TextView)view).setAutoLinkMask(Linkify.ALL);
                text(url);
            }
        }
        return self();
    }
791339
public void addFile(String url) {
        int count = windowMenu.getItemCount();
        JMenuItem item;
        if (count == 4) {
            windowMenu.addSeparator();
            count++;
        }
        JMenuItem lastItem = windowMenu.getItem(count -1);
        boolean hasMoreWin = false;
        int maxWin = 5;
        if (lastItem != null &&
           lastItem.getText().equals("More Windows...")) {
            hasMoreWin = true;
            maxWin++;
        }
        if (!hasMoreWin && count - 4 == 5) {
            windowMenu.add(item = new JMenuItem("More Windows...", 'M'));
            item.setActionCommand("More Windows...");
            item.addActionListener(this);
            return;
        } else if (count - 4 <= maxWin) {
            if (hasMoreWin) {
                count--;
                windowMenu.remove(lastItem);
            }
            String shortName = SwingGui.getShortName(url);

            windowMenu.add(item = new JMenuItem((char)('0' + (count-4)) + " " + shortName, '0' + (count - 4)));
            if (hasMoreWin) {
                windowMenu.add(lastItem);
            }
        } else {
            return;
        }
        item.setActionCommand(url);
        item.addActionListener(this);
    }
177613
private boolean isInvalidURL(String url) {
        try {
            final URL u = new URL(url);
            u.toURI();
        } catch (MalformedURLException | URISyntaxException e) {
            LOGGER.trace("URL is invalid: {}", url);
            return true;
        }
        return false;
    }
502376
@SuppressWarnings("ResultOfMethodCallIgnored")
    public static boolean download(String downloadURL) {
        if (Checker.isHyperLink(downloadURL) && checkDownloadPath()) {
            logger.info("ready for download url: " + downloadURL + " storage in " + storageFolder);
        } else {
            logger.info("url or storage path are invalidated, can't download");
            return false;
        }
        int byteRead;
        String log = "download success from url '" + downloadURL + "' to local '";
        try {
            String fileName = checkPath(storageFolder + ValueConsts.SEPARATOR + Formatter.getFileName(downloadURL));
            String tmp = fileName + ".tmp";
            File file = new File(tmp);
            log += file.getAbsolutePath() + "'";
            URL url = new URL(downloadURL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            InputStream inStream = NetUtils.getInputStreamOfConnection(conn);
            if (conn.getResponseCode() != ValueConsts.RESPONSE_OK || conn.getContentLength() <= 0) {
                return false;
            }
            FileOutputStream fs = new FileOutputStream(file);
            if (!file.exists()) {
                file.createNewFile();
            }
            byte[] buffer = new byte[1024];
            while ((byteRead = inStream.read(buffer)) != -1) {
                fs.write(buffer, 0, byteRead);
            }
            fs.flush();
            inStream.close();
            fs.close();
            file.renameTo(new File(fileName));
            logger.info(log);
            return true;
        } catch (IOException e) {
            log = log.replace("success", "error") + ", message: " + e.getMessage();
            logger.error(log);
            return false;
        }
    }
1288141
static String [] searchJarFSForClasses( URL url ) throws IOException {
        try {
            try {
                FileSystems.newFileSystem(url.toURI(), new HashMap<>());
            } catch (FileSystemAlreadyExistsException e) { /* ignore */ }

            Path path = FileSystems.getFileSystem(url.toURI()).getPath("/");

            return Files.walk(path).map(Path::toString)
                    .filter(BshClassPath::isClassFileName)
                    .map(BshClassPath::canonicalizeClassName)
                    .toArray(String[]::new);
        } catch (URISyntaxException e) { /* ignore */ }
        return new String[0];
    }
661933
@Nonnull
    /*package*/ static long getModificationDate(@Nonnull URL url) throws IOException {
        URLConnection uc = url.openConnection();
        
        // It prevents file descriptor leak if the URL references a file within JAR
        // See JENKINS-37332  for more info
        // The code idea is taken from https://github.com/jknack/handlebars.java/pull/394
        if (uc instanceof JarURLConnection) {
            final JarURLConnection connection = (JarURLConnection) uc;
            final URL jarURL = connection.getJarFileURL();
            if (jarURL.getProtocol().equals("file")) {
                uc = null;
                String file = jarURL.getFile();
                return new File(file).lastModified();
            } else {
                // We access the data without file protocol
                if (connection.getEntryName() != null) {
                    LOGGER.log(WARNING, "Accessing modification date of {0} file, which is an entry in JAR file. "
                        + "The access protocol is not file:, falling back to the default logic (risk of file descriptor leak).",
                            url);
                }
            }
        }
        
        // Fallbak to the default implementation
        return uc.getLastModified();
    }
1231346
private boolean isJarFile(URL resourceLocation) {

    String resourceLocationString = resourceLocation.toExternalForm();

    return resourceLocationString.startsWith("jar:file:") || resourceLocationString.contains(".jar!");
  }
707487
public boolean hasToolPathForUrl(String url) {

        List<String> toolPaths = m_urls.getObjectList(url);
        return ((toolPaths != null) && !toolPaths.isEmpty());
    }