假设您使用的是任何类型的fileIO,
public class example{
public Example(){
File file = new File(getClass().getProtectionDomain().getCodeSource().getLocation());
//file IO process ....
}
}
Run Code Online (Sandbox Code Playgroud)
通过使用getClass().getProtectionDomain().getCodeSource().getLocation()你将获得"example.jar"的完整路径.那么,如何获得该文件位置但没有"example.jar"?
(实际上是jar所在的文件夹,但不是jar本身的链接)
| 归档时间: |
|
| 查看次数: |
96 次 |
| 最近记录: |