Why does IResource.getRawLocation() return null for IProject(为什么 IResource.getRawLocation() 为 IProject 返回 null)
问题描述
我需要一个项目文件夹的绝对位置,所以我尝试了
I need the absolute location of a project folder, so I tried
project.getRawLocation()
但这会返回 null
(至少在我使用 Import ... Existing projects into workspace 手动导入项目的情况下,我已经检查了 将项目复制到工作区复选框).
but this returns null
(at least in my case in which I have imported the project manually using Import ... Existing projects into workspace and I have checked the Copy projects into workspace checkbox).
事情是这样的
project.getParent().getRawLocation()
返回正确的 /work/Projekte/runtime-MyProduct.product
和
project.members()[0].getRawLocation()
返回 /work/Projekte/runtime-MyProduct.product/Test/.cproject
这也是正确的.
returns /work/Projekte/runtime-MyProduct.product/Test/.cproject
which is correct as well.
因此,我希望如此
project.getRawLocation()
会返回 /work/Projekte/runtime-MyProduct.product/Test
,但它会返回 null
.
would return /work/Projekte/runtime-MyProduct.product/Test
, but it returns null
.
谁能解释和/或告诉我哪里错了?
Can anyone explain and/or show me where I'm wrong?
推荐答案
getRawLocation()
说
如果此资源是现有项目,则返回的路径将为等于项目描述中的位置路径.
If this resource is an existing project, the returned path will be equal to the location path in the project description.
以及项目描述的 JavaDoc IProjectDescription.getLocation()
说:
and the JavaDoc for the project description IProjectDescription.getLocation()
says:
如果应该使用默认位置,则返回null
null is returned if the default location should be used
getLocation()
调用会返回一个路径.
The getLocation()
call will return a path.
这篇关于为什么 IResource.getRawLocation() 为 IProject 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 IResource.getRawLocation() 为 IProject 返回 null
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01