OKay Guys, I approached the same old method for this. I used an Iterator
to walk through the ArrayList
and used it this way:
static void RecursiveFolderFinder(String Root)
{
Iterator<Folder> Folder = ListOfFolders.iterator();
while (Folder.hasNext())
{
Folder curFolder = Folder.next();
if (curFolder.getParent().equals(Root))
{
OutputList += " " + curFolder.getName() + " ";
OutputList += "{";
RecursiveFolderFinder(curFolder.getName());
if (OutputList.substring(OutputList.length()-1, OutputList.length()).equals("{"))
OutputList = OutputList.substring(0, OutputList.length()-1);
else if (!OutputList.substring(OutputList.length()-1, OutputList.length()).equals(" "))
OutputList += " }";
else
OutputList += "}";
}
}
}
I know, this kind of string manipulation is crazy and weak, I used his for making sure, no one else uses such a funny one! Just sarcastic. Thanks for @mrhobo's answer. If anyone could suggest me a better output, awesome then!