码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2019-08-29 11:16:43      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:nbsp   too   path   new   uri   resources   get   project   eclipse   

(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);   

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

标签:nbsp   too   path   new   uri   resources   get   project   eclipse   

原文地址:https://www.cnblogs.com/Soy-technology/p/11428277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!