在Java中查找工作目录的基本路径 [英] Find Base path of the working directory in Java

查看:51
本文介绍了在Java中查找工作目录的基本路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse Luna RCP.在插件的代码中,我需要工作空间的路径.我使用了以下代码:

I am using Eclipse Luna RCP. In the code of my plugin, I want the path of my workspace. I have used the following code:

String basePath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();

这应该给出:

/home/esghsni/avroWorkspace/AvroDesigner

但是给出的路径不正确,其中包括路径eclipse rcp的存储目录.

But it is give incorrect path which include path the directory where eclipse rcp is stored.

我已经检查了所有相关问题,但都无济于事.我也尝试解码返回的路径(使用 URLDecoder()),但是它总共提供了其他一些路径.任何帮助将不胜感激.谢谢!!

I have checked all the related questions but none helped. I have also tried decoding the path returned (using URLDecoder()), but it gave some other path altogether. Any kind of help would be appreciated. Thank you!!

推荐答案

您可以尝试以下操作:

 System.out.println(System.getProperty("user.dir"));

这篇关于在Java中查找工作目录的基本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆