Here you can find the source of getPath(String resoureLocation)
Parameter | Description |
---|---|
resoureLocation | the location of the resource. |
Parameter | Description |
---|---|
URISyntaxException | if this URL is not formatted strictly according to to RFC2396and cannot be converted to a URI. |
public static String getPath(String resoureLocation) throws URISyntaxException
//package com.java2s; //License from project: Open Source License import java.net.URISyntaxException; public class Main { /**/*from w ww .j a v a 2 s. c o m*/ * This function returns the absolute path of a class path resource. * * @param resoureLocation * the location of the resource. * @return the {@code Path} of the class pat resource. * @throws URISyntaxException * if this URL is not formatted strictly according to to RFC2396 * and cannot be converted to a URI. */ public static String getPath(String resoureLocation) throws URISyntaxException { return getContextClassLoader().getResource(resoureLocation).toURI().getPath(); } private static ClassLoader getContextClassLoader() { return Thread.currentThread().getContextClassLoader(); } }