当前位置: 移动技术网 > IT编程>开发语言>Java > java 获取项目文件路径实现方法

java 获取项目文件路径实现方法

2019年07月22日  | 移动技术网IT编程  | 我要评论
this.getclass().getresource("/").getpath().substring(1)获得路径为e:/myeclipse/test/webroot/

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)效果一样

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网