Get the absolute path of the currently edited file in Eclipse

后端 未结 6 626
予麋鹿
予麋鹿 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:41

    For me, this run ok.

    IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();

    File file = workSpaceRoot.getRawLocation().makeAbsolute().toFile();

    file list from this location:

    File[] files = file.listFiles();

提交回复
热议问题