Java ClassLoader Load getPath(String resoureLocation)

Here you can find the source of getPath(String resoureLocation)

Description

This function returns the absolute path of a class path resource.

License

Open Source License

Parameter

Parameter Description
resoureLocation the location of the resource.

Exception

Parameter Description
URISyntaxException if this URL is not formatted strictly according to to RFC2396and cannot be converted to a URI.

Return

the Path of the class pat resource.

Declaration

public static String getPath(String resoureLocation) throws URISyntaxException 

Method Source Code

//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();
    }
}

Related

  1. getLocalFile(final String aLocalPath)
  2. getLog4jPropertiesLocation()
  3. getManifestInfo()
  4. getMetadataSpecialSymbolsXml()
  5. getPath(final String fileName)
  6. getProhibitedProxyInterfaces()
  7. getProperties(String bundleName, String fileName)
  8. getProperty(String propertyName)
  9. getReader(final String name, final String encoding)