class FileUtils {

    public static List<URL> getAllClassPathUrls(ClassLoader classLoader) {
        try {
            List<URL> list = new ArrayList();
            Enumeration<URL> iterator = classLoader.getResources("");
            while (iterator.hasMoreElements()) {
                URL url = iterator.nextElement();
                list.add(url);
            }
            if (classLoader instanceof URLClassLoader) {
                for (URL u : ((URLClassLoader) classLoader).getURLs()) {
                    URL url = new URL("jar:" + u + "!/");
                    list.add(url);
                }
            } else {
                String classpath = System.getProperty("java.class.path");
                if (classpath != null && !classpath.isEmpty()) {
                    String[] classpathEntries = classpath.split(File.pathSeparator);
                    for (String classpathEntry : classpathEntries) {
                        if (classpathEntry.endsWith(".jar")) {
                            String entryWithForwardSlashes = classpathEntry.replaceAll("\\\\", "/");
                            boolean startsWithSlash = entryWithForwardSlashes.startsWith("/");
                            URL url = new URL("jar:file:" + (startsWithSlash ? "" : "/") + entryWithForwardSlashes + "!/");
                            list.add(url);
                        }
                    }
                }
            }
            return list;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private  FileUtils();

}