Java工作区和文件路径 [英] Java workspace and file path

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

问题描述

我可能很容易解决问题. 我的项目中有一个文件夹,想要使用相对路径来获取它:

I have a probably easy to solve problem. I am having a folder in my project and want to get it using the relative path:

new File("/folder")

这给了我FileNotFoundException

如果我这样尝试

new File("d:/workspace/project/folder")

有效

我怀疑由于这个原因它不起作用: new File("").getAbsolutePath()返回:D:\eclipse 所以不是工作空间的路径.

I suspect that it does not work because of this: new File("").getAbsolutePath() returns : D:\eclipse So not the path of the workspace.

我做错了还是需要在Eclipse中更改某些设置

Am I doing something wrong or do I need to change some settings in eclipse

推荐答案

只是在djna建议的运行配置"中找到了我的答案,但没有在环境"选项卡中,而是在参数"选项卡中.有一个工作目录部分,其中设置了d:\ eclipse,需要将其设置为$ {workspace_loc:myproject}

Just found my answer in Run Cofigurations like djna suggested, but not in the Environment Tab but in the Arguments Tab. There is a working directory section in which d:\eclipse was set and which needed to be set to ${workspace_loc:myproject}

这篇关于Java工作区和文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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