标签:
如图,eclipse中我的包结构为:,我在 spt.app.MainFrame 中可以通过一下代码段使用资源:
public static Object obj = ImageIconProxy.class.getClassLoader().getResource("img/absent.png");
但是我们不能在A类中,引用别的类声明类似上面的方法,例如,我们再 spt.proxy.ImageIconProxy 类中声明:
public static Object obj = ImageIconProxy.class.getClassLoader().getResource("img/absent.png");
然后再 spt.app.MainFrame 中引用:Object obj = ImageIconProxy.obj; //这样是无法获取到的.
java 引用资源-ClassLoader.getResource()方法
标签:
原文地址:http://www.cnblogs.com/listened/p/4181478.html