Get the absolute path of the currently edited file in Eclipse

后端 未结 6 648
予麋鹿
予麋鹿 2021-02-04 06:13

I\'d like to write a plugin that does something with the currently edited file in Eclipse. But I\'m not sure how to properly get the file\'s full path.

This is what I do

6条回答
  •  无人共我
    2021-02-04 06:35

    I think a more Java friendly solution would be to do use the following:

    IResource.getLocation().toFile()
    

    This takes advantage of the IPath API (the getLocation() part) and will return a java.io.File instance. Of course the other answers will probably get you to where you want to be too.

    On a tangential note, I find the IDE class (org.eclipse.ui.ide.IDE) a useful utility resource when it comes to editors.

提交回复
热议问题