Finding a file in a component using java api
![]()
I can find a file that is at the root folder using the folliwng methods
IConfiguration iconfig = (IConfiguration) workspace.configuration(component); IFolderHandle root = iconfig.rootFolderHandle(MONITOR); IVersionableHandle filePathHandle = iconfig.resolvePath(root,fileName, MONITOR); How do I find the file if it is not at the root folder level?? |
One answer
![]()
there should be a simpler way.......
public IVersionableHandle findfile(IFolderHandle root,IConfiguration iconfig,String fileName) throws TeamRepositoryException { String fileNamePath[] = {fileName}; IVersionableHandle filePathHandle = null; // Check if file at this folder level filePathHandle = iconfig.resolvePath(root,fileNamePath, MONITOR); if (filePathHandle != null) { return filePathHandle; } // Check this file sub folders Map<String> childEntries = iconfig.childEntries(root,MONITOR); for(Map.Entry<String> next : childEntries.entrySet()) { IVersionableHandle nextVersionable = next.getValue(); if (nextVersionable instanceof IFolderHandle) { filePathHandle = findfile((IFolderHandle) nextVersionable,iconfig,fileName); if (filePathHandle != null) { break; } } } return filePathHandle; } |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.