String className = Appender.class.getName(); className = className.replace('.', '/'); String resource = "/" + className + ".class"; URL url = Appender.class.getResource(resource); System.out.println(url.getFile());
//输出结果:
//file:/E:/JavaLib/log4j/log4j-1.2.14.jar!/org/apache/log4j/Appender.class
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/11066.html