public class PathTest {
    public static void main(String[] args) {
        //获取根路径三种方式
        System.out.println(PathTest.class.getClassLoader().getResource(""));
        System.out.println(ClassLoader.getSystemClassLoader().getResource(""));
        System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));
        //获取当前类所在路径
        System.out.println(PathTest.class.getResource(""));
    }
}

 

posted on 2016-12-18 20:22  woqiaoxun  阅读(207)  评论(0编辑  收藏  举报