在类库的开发过程中,有些时候为了self-contain的原因,我们希望所有的资源都打包在jar中,但是有些工具好像无法支持从classpasth直接获取比如velocity的模板合并,此时我们就知道class所在的jar,然后通过jar方式加载velocity资源模板。

String jarFilePath = clazz.class.getProtectionDomain().getCodeSource().getLocation().getFile();
// URL Decoding
jarFilePath = java.net.URLDecoder.decode(jarFilePath, "UTF-8");
  1. String jarFilePath = clazz.class.getProtectionDomain().getCodeSource().getLocation().getFile();
  2. // URL Decoding
  3. jarFilePath = java.net.URLDecoder.decode(jarFilePath, "UTF-8");

最新文章

  1. 给缺少Python项目实战经验的人
  2. C++中int,float,string,char*的转换(待续)
  3. NEC学习 ---- 模块 -多行式面包屑导航
  4. EXCEL 保存之前校验
  5. Apache Spark源码走读之20 -- ShuffleMapTask计算结果的保存与读取
  6. HDU 5441 Travel (并查集+数学+计数)
  7. JDBC连接(MySql)数据库步骤,以及查询、插入、删除、更新等十一个处理数据库信息的功能
  8. Lambda(Linq)
  9. ogg的孩子-无损音频编解码flac
  10. 在java中实现数据导入excel表格中
  11. 分享一个公众号h5裂变吸粉源码工具
  12. 如何将文章列表用<li>分两列显示
  13. rsync命令解析
  14. 跟我学SharePoint 2013视频培训课程——理解SharePoint网站的体系结构(3)
  15. DispatcherServlet的url mapping为“/”时,对根路径访问的处理
  16. CF3A 【Shortest path of the king】
  17. C# 实现将listview中已经显示的数据导出到Access 数据库
  18. 學習Extjs比較好的資源
  19. 最大匹配算法 (Maximum Matching)
  20. “全栈2019”Java第六十章:如何定义接口

热门文章

  1. Could not find the Visual SourceSafe Internet Web Service connection information for the specified database Would you like to launch the Visual sourceSafe connection wizard?
  2. WinStore控件之Button
  3. ubuntu 修改默认root及密码
  4. 正向代理VS反向代理 总结
  5. windows环境下配置php和redis
  6. MYSQL开发性能研究——批量插入的优化措施
  7. MyBatis知多少(8)关系型数据库
  8. js中的执行上下文,菜鸟入门基础。
  9. 在C函数中保存状态:registry、reference和upvalues
  10. CentOS linux系统搭建LAMP环境