This java service will list all the files and the files in the sub-directories with full path names.
IDataCursor pipelineCursor = pipeline.getCursor(); String dirPath = IDataUtil.getString( pipelineCursor, "dirPath" ); pipelineCursor.destroy(); List<String> output=new ArrayList<String>(); List<String> tempPlaceHolder=new ArrayList<String>(); output=extract(dirPath,tempPlaceHolder); IDataUtil.put( pipelineCursor, "dirList", output.toArray(new String[output.size()])); pipelineCursor.destroy();Shared Code:
public static List<String> extract(String directoryName, List<String> outFiles){ File directory=new File(directoryName); File[] fileList=directory.listFiles(); String outFileName; for(int i=0;i<fileList.length;i++){ if(fileList[i].isFile()){ outFileName=fileList[i].toString(); outFiles.add(outFileName); } else{ outFileName=fileList[i].toString(); outFiles.add(outFileName); extract(outFileName,outFiles); } } return outFiles; }
No comments:
Post a Comment