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
基础教程推荐
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
