Java implementation method for obtaining project file path

this. getClass(). getResource("/"). getPath(). Substring (1) gets the path e: / MyEclipse / test / Webroot / WEB-INF / classes /, that is, the home directory.

this. getClass(). getResource(""). getPath(). Substring (1) gets the path e: / MyEclipse / test / Webroot / WEB-INF / classes / net / hncu / db /, which is the relative path of this file.

this. getClass(). getResource("."). getPath(). Substring (1) and this getClass(). getResource(""). getPath(). Substring (1) has the same effect

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>