如何以编程方式从全部类名中找到eclipse中的java文件? [英] How to programmatically find a java file in eclipse from full classname?
本文介绍了如何以编程方式从全部类名中找到eclipse中的java文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
在 IJavaProject.findType(name)
方法。一旦你有一个 IType
,你可以使用getPath()或getResource()方法找到文件。此方法搜索项目和该项目可见的所有内容。要搜索整个工作空间,请遍历工作空间中的所有Java项目,依次调用findType()方法。
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?
解决方案
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文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文