get Absolute Path for class loader - Java Reflection

Java examples for Reflection:Class Loader

Description

get Absolute Path for class loader

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String path = "java2s.com";
        System.out.println(getAbsolutePath(path));
    }/*www.j a  va2  s  .  c o m*/

    public static String getAbsolutePath(String path) {
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        String absolutePath = classLoader.getResource(path).getFile();
        return absolutePath;
    }
}

Related Tutorials