Here you can find the source of getClasspathUrl(final Class> aClass, final String aPath)
public static URL getClasspathUrl(final Class<?> aClass, final String aPath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; public class Main { public static final String CLASSPATH_PREFIX = "classpath:"; public static URL getClasspathUrl(final Class<?> aClass, final String aPath) throws IOException { if (aPath != null && aPath.startsWith(CLASSPATH_PREFIX)) { return getResourceUrl(aClass, aPath.substring(CLASSPATH_PREFIX.length())); } else {// www .ja v a 2s .c o m return null; } } public static URL getResourceUrl(final Class<?> aClass, final String aPath) throws IOException { final URL url = aClass.getResource(aPath); if (url == null) { throw new FileNotFoundException("Resource not found for " + aClass.toString() + ": " + aPath); } else { return url; } } }