How to programmatically find a java file in eclipse from full classname?(如何以编程方式从完整的类名中找到 eclipse 中的 java 文件?)
问题描述
在 Eclipse 插件中,我想在编辑器中打开一个文件.我知道完整的包和类名,如何从中确定java文件的路径?
Inside an eclipse plugin, I'd like to open a file in editor. I know the full package and class name, how can I determine the path of the java file from this?
推荐答案
看看IJavaProject.findType(name)
方法.一旦有了 IType
,就可以使用 getPath() 或 getResource() 方法来定位文件.此方法搜索整个项目以及该项目中可见的所有内容.要搜索整个工作区,请遍历工作区中的所有 Java 项目,依次调用每个项目的 findType() 方法.
Take a look at IJavaProject.findType( name )
method. Once you have an IType
, you can use getPath() or getResource() methods to locate the file. This method searches across a project and everything visible from that project. To search the whole workspace, iterate through all the Java projects in the workspace, calling the findType() method on each in turn.
这篇关于如何以编程方式从完整的类名中找到 eclipse 中的 java 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何以编程方式从完整的类名中找到 eclipse 中的 java 文件?


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01