/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * */ /** * @author hariharan_kumar * */ public class Dfs { List<String> directoryLists; /** * */ public Dfs() { directoryLists = new ArrayList<String>(); } /** * @param args */ Dfs df = new Dfs(); df.iterate("G:/jbossTest"); df.displayDirList(); } { for(int i = 0;i < file_array.length;i++) { if(file_array[i].isDirectory()) { //System.out.println("Directory is : " + file_array[i].getName()); directoryLists.add(file_array[i].getAbsolutePath()); iterate(file_array[i].getAbsolutePath()); } else if (file_array[i].isFile()) { //System.out.println("File is : " + file_array[i].getAbsolutePath()); } else if(file_array.length == i) { return; } } } public void displayDirList() { Iterator<String> i = directoryLists.iterator(); while(i.hasNext()) { } } }