之前有同事问到IFile与File之间的互换问题,当时自己也不清楚,今天在阅读代码的时候发现了他们之间的互换是非常方便的。
IProject fsProject = ResourceModelUtils.getProject(project);
IFolder tmpFolder = ResourceUtils.getFolder(fsProject, RepositoryConstants.TEMP_DIRECTORY, true);
String tmpFilename = "DOC" + documentationItem.getProperty().getId();
IFile fileTmp = tmpFolder.getFile(tmpFilename);//Get IFile reference by file name;
File file = fileTmp.getLocation().toFile(); //Get File reference by IFile reference.
File newFile = new File(fileTmp.getLocation().toOSString()); //Convert IFile to File.
IFile的功能比File强大且方便多了。
爱生活,爱Eclipse!
posted on 2007-12-18 14:24
jackgogogo(Dengues Studio) 阅读(2895)
评论(1) 编辑 收藏