@@ -0,0 +1,2186 @@
+package net.common.utils;%0A%0Aimport java.io.File;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0A%0A/**%0A * %E6%8F%90%E4%BE%9BURL%E5%8F%8AURI%E7%9A%84%E7%9B%B8%E5%85%B3%E5%A4%84%E7%90%86%E5%8A%9F%E8%83%BD%0A * User: shijingui%0A * Date: 2015/11/14%0A */%0Apublic class UrlUtil %7B%0A%0A    /**%0A     * URL prefix for loading from the file system: %22file:%22%0A     */%0A    public static final String FILE_URL_PREFIX = %22file:%22;%0A%0A    private UrlUtil() %7B%0A        super();%0A    %7D%0A%0A    /**%0A     * %E5%8F%96%E5%BE%97%E8%B5%84%E6%BA%90%E5%AE%9A%E4%BD%8D%E5%AF%B9%E8%B1%A1%0A     *%0A     * @param resourceLocation %E8%B5%84%E6%BA%90%E4%BD%8D%E7%BD%AE%0A     * @throws RuntimeException %E6%8A%9B%E5%87%BA%E6%9D%A1%E4%BB%B6%EF%BC%9A%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E4%B8%8D%E6%98%AF%E4%B8%80%E4%B8%AAURL, %E6%96%87%E4%BB%B6%E8%B5%84%E6%BA%90%E4%B8%8D%E5%AD%98%E5%9C%A8%0A     */%0A    public static URL getURL(String resourceLocation) throws RuntimeException %7B%0A        return getURL(resourceLocation, null);%0A    %7D%0A%0A    /**%0A     * %E5%8F%96%E5%BE%97%E8%B5%84%E6%BA%90%E5%AE%9A%E4%BD%8D%E5%AF%B9%E8%B1%A1%0A     *%0A     * @param resourceLocation %E8%B5%84%E6%BA%90%E4%BD%8D%E7%BD%AE%0A     * @throws RuntimeException %E6%8A%9B%E5%87%BA%E6%9D%A1%E4%BB%B6%EF%BC%9A%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E4%B8%8D%E6%98%AF%E4%B8%80%E4%B8%AAURL, %E6%96%87%E4%BB%B6%E8%B5%84%E6%BA%90%E4%B8%8D%E5%AD%98%E5%9C%A8%0A     */%0A    public static URL getURL(String resourceLocation, ClassLoader loader) throws RuntimeException %7B%0A        if (resourceLocation.startsWith(FILE_URL_PREFIX)) %7B%0A            resourceLocation = resourceLocation.substring(FILE_URL_PREFIX.length());%0A        %7D%0A        File file = new File(resourceLocation);%0A        if (file.exists()) %7B%0A            try %7B%0A                return new URL(resourceLocation);%0A            %7D catch (MalformedURLException ex) %7B%0A                try %7B%0A                    return new URL(FILE_URL_PREFIX + resourceLocation);%0A                %7D catch (MalformedURLException ex2) %7B%0A                    throw new RuntimeException(%22The %5BresourceLocation=%22 + resourceLocation + %22%5D is neither a URL not a well-formed file path.%22, ex2);%0A                %7D%0A            %7D%0A        %7D%0A        URL url = null;%0A        if (loader != null) %7B%0A            url = loader.getResource(resourceLocation);%0A        %7D%0A        if (url == null) %7B%0A            url = Thread.currentThread().getContextClassLoader().getResource(resourceLocation);%0A            if (url == null) %7B%0A                url = UrlUtil.class.getClassLoader().getResource(resourceLocation);%0A                if (url == null) %7B%0A                    throw new RuntimeException(%22Class path resource %5B%22 + resourceLocation + %22%5D cannot be resolved to URL because it does not exist.%22);%0A                %7D%0A            %7D%0A        %7D%0A        return url;%0A    %7D%0A%7D%0A

add UrilUtil class