Here you can find the source of getResourceRootPath(Class> resourceClass, String resourceName)
public static Path getResourceRootPath(Class<?> resourceClass, String resourceName)
//package com.java2s; //License from project: Apache License import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static Path getResourceRootPath(Class<?> resourceClass, String resourceName) { URL url = resourceClass.getResource(resourceName); try {/* w w w . j av a 2 s .com*/ return Paths.get(url.toURI()).getParent(); } catch (URISyntaxException e) { throw new IllegalStateException(e); } } }