Here you can find the source of getParentResource(final Class> c, final String resource)
public static URL getParentResource(final Class<?> c, final String resource)
//package com.java2s; //License from project: Open Source License import java.net.URL; public class Main { public static URL getParentResource(final Class<?> c, final String resource) { String name = c.getName(); name = name.substring(0, name.lastIndexOf(".")); name = name.substring(0, name.lastIndexOf(".") + 1); name = name.replace(".", "/"); return c.getClassLoader().getResource(name + resource); }//from w w w .j a v a2 s.co m }