Hi,
I’m trying to extract files/folders from directories/subdirectories and put everything in a list. I made it work in Java. Here’s the code snippet i have tried so far.
In Shared tab -
SOURCE
public static void Extract(String directoryName)
{
try{
File directory = new File(directoryName);
//get all the files from a directory
File[] fList = directory.listFiles();
//for (File file : fList)
for (int i = 0; i < fList.length; i++)
{
if (fList[i].isFile()){
} else if (fList[i].isDirectory())
{
//Extract(file.getAbsolutePath());
dirList[i].add(directory.getAbsolutePath());
i++;
}
}
}
catch(Exception exception)
{
//throw new ServiceException("Internal Server Error - Files names could not be retrieved");
}
}
Code
IDataCursor pipelineCursor = pipeline.getCursor();
String dirPath = IDataUtil.getString( pipelineCursor, "dirPath" );
pipelineCursor.destroy();
ArrayList<Object> dirList=new ArrayList<Object>();
Extract(dirPath);
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
//String[] dirList = new String[];
//dirList[] = "dirList";
IDataUtil.put( pipelineCursor_1, "dirList", dirList);
pipelineCursor_1.destroy();
In the source, what im trying to do is, if its a directory im trying to call the same function again. but im not able to get the list of folders in the directories/subdirectories.
Please help me out in this.
Thanks
#Integration-Server-and-ESB#Flow-and-Java-services#webMethods