Here you can find the source of getResourcePath(Object object, String resource)
Parameter | Description |
---|---|
object | the requested object type |
the | desired resource |
public static String getResourcePath(Object object, String resource)
//package com.java2s; //License from project: Open Source License import java.net.URISyntaxException; import java.net.URL; public class Main { /**// www .ja va 2 s. c o m * Return the fully qualified path of the requested resource object. * @param object the requested object type * @param the desired resource * @return its fully qualified path name. */ public static String getResourcePath(Object object, String resource) { URL resourceURL = object.getClass().getClassLoader().getResource(resource); if (resourceURL != null) { try { return resourceURL.toURI().getPath(); } catch (URISyntaxException e) { return null; } } else { return null; } } }