Java Utililty Methods ClassLoader Load

List of utility methods to do ClassLoader Load

Description

The list of methods to do ClassLoader Load are organized into topic(s).

Method

Stringget(final String key, final String filename)
get
Properties props;
try {
    props = load(new File(filename));
} catch (final IOException e) {
    return "getting key " + key + " from file " + filename + " failed " + e;
return (props.getProperty(key));
StringgetAbsoluteBasePath()
get Absolute Base Path
if (absoluteBasePath == null) {
    if (APPS_JAR_DIRECTORY != null) {
        absoluteBasePath = APPS_JAR_DIRECTORY;
    } else {
        URL url = Thread.currentThread().getContextClassLoader().getResource("schemas/common.xsd");
        absoluteBasePath = url.getPath();
        absoluteBasePath = absoluteBasePath.substring(0, absoluteBasePath.length() - 18); 
        absoluteBasePath = absoluteBasePath.replace('\\', '/');
...
StringgetAbsolutePath(String file)
get Absolute Path
return new File(getImpFolder(), file).getAbsolutePath();
StringgetAbsolutePathEssenceDesc(String file)
get Absolute Path Essence Desc
return new File(getImpFolderEssenceDesc(), file).getAbsolutePath();
File[]getAllArquillianLibs()
get All Arquillian Libs
URL urlSystemResources = ClassLoader.getSystemResource("");
File dirArquillianLibs = new File(new File(urlSystemResources.getFile()).getParentFile(),
        "arquillian-libs");
return dirArquillianLibs.listFiles();
PropertiesgetAsProperties(final String name)
Load properties from the given name.
Properties props = new Properties();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = classLoader.getResource(name);
if (url != null) {
    try {
        props.loadFromXML(url.openStream());
    } catch (InvalidPropertiesFormatException e) {
        props.load(url.openStream());
...
URLgetBaseDir()
Gets the application base directory.
try {
    Class<?> c = (new Object() {
        public String toString() {
            return super.toString();
    }).getClass();
    ClassLoader cl = c.getClassLoader();
    URL url = cl.getResource(".");
...
byte[]getBytes(File file)
Read a file completely and return a byte array containing the data.
return getBytes(file, -1);
InputStreamgetConfigFileInputStream(String configFilePath)
get Config File Input Stream
if (null == configFilePath) {
    throw new IOException("Could not find config file, name not specified");
HashSet<URL> resources = new HashSet<URL>(findResources(configFilePath));
if (resources.isEmpty()) {
    File configFile = new File(configFilePath);
    if (configFile.exists()) {
        return new FileInputStream(configFile);
...
StringgetContentFromFile(String fileName, Object context)
get Content From File
File file = getFileFromPath(context, fileName);
FileInputStream fin = new FileInputStream(file);
String response = convertStreamToString(fin);
fin.close();
return response;