java 引用资源-ClassLoader.getResource()方法
2024-10-19 02:23:58
如图,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; //这样是无法获取到的.
最新文章
- 微软新神器-Power BI横空出世,一个简单易用,还用得起的BI产品,你还在等什么???
- ExtJS in Review - xtype vs. alias
- IO多路复用及ThreadingTCPServer源码阅读
- 20145209&;20145309信息安全系统设计基础实验报告 (5)
- Mono.Posix.dll文件
- Unity3D面试题汇总
- 【ArcGIS二次开发】CreateFeature报错(HRESULT E_FAIL)
- PHP strrpos strpos strstr strrchr 区别
- unity3d脚本编程
- Unity学习笔记(4):依赖注入
- Kafka的消息格式
- Android自动化测试介绍
- Perl中检测标准输入使用的字符集
- CentOS 6.4 配置 Hadoop 2.6.5
- MySQL 存储过程 if语句
- spring 装配
- 剑指Offer_编程题_1
- pyqt5-顶层窗口特定操作-图标和标题和不透明度
- 启动docker容器时的Error response from daemon: devmapper: Error mounting: invalid argument. 错误解决
- python:推导式套路