手机
当前位置:查字典教程网 >编程开发 >Java >java 获取项目文件路径实现方法
java 获取项目文件路径实现方法
摘要:this.getClass().getResource("/").getPath().substring(1)获得路径为E:/myeclip...

this.getClass().getResource("/").getPath().substring(1)获得路径为E:/myeclipse/test/WebRoot/WEB-INF/classes/,即主目录。

this.getClass().getResource("").getPath().substring(1)获得路径为E:/myeclipse/test/WebRoot/WEB-INF/classes/net/hncu/db/,即本文件的相对路径。

this.getClass().getResource(".").getPath().substring(1)和this.getClass().getResource("").getPath().substring(1)效果一样

【java 获取项目文件路径实现方法】相关文章:

java获取时间的方法总结

Java 获取指定日期的实现方法总结

java定时任务的实现方法

java web项目里ehcache.xml介绍

java中读取配置文件中数据的具体方法

Java自动解压文件实例代码

java servlet 几种页面跳转的方法

java 读写文件[多种方法]

深入分析java文件路径的详解

java获取web容器地址的方法

精品推荐
分类导航