Eclipse插件开发中File和IFile的转换

(1) File转IFile

  第一种方法:

    IFile[] ifile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI());

  第二种方法:

    String filepath =file.getPath();

    IProject proj =ResourcesPlugin.getWorkspace().getRoot().getProject(projName);

    String path =filepath.substring(proj.getLocation().toString().length() + 1);

    IFile file =proj.getFile(path);  

(2) IFile转File

  File file = ifile.getLocation().toFile;

    或者

  File = newFile(ifile.getLocation().toOSString);   

posted @ 2019-08-29 10:37  SoyWang  阅读(557)  评论(0编辑  收藏  举报