读书人

Java基础1 加载资源

发布时间: 2012-12-23 11:28:15 作者: rapoo

Java基础一 加载资源

一 加载资源,一般两种方式,class使用绝对路径,thread使用相对包路径

???URL t = Thread.currentThread().getContextClassLoader().getResource("META-INF/log4j.properties");

? InputStream in2 = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/log4j.properties");


???URL t1 = Bootstrap.class.getResource("/META-INF/log4j.properties");

? ?InputStream in =? Bootstrap.class?.getResourceAsStream("/META-INF/log4j.properties");
??

?

?

?

?

?

读书人网 >编程

热点推荐