Created
June 29, 2009 07:19
-
-
Save jonasbjork/137512 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iteratedirs | |
import java.io.*; | |
import java.util.Iterator; | |
//import java.util.Vector; | |
import java.util.ArrayList; | |
/** | |
* | |
* @author jonas | |
*/ | |
public class Main { | |
/** | |
* @param args the command line arguments | |
*/ | |
//private static Vector<String> v; | |
private static ArrayList<String> al; | |
public static void main(String[] args) { | |
//v = new Vector(); | |
al = new ArrayList(); | |
String path = "c:/test"; | |
searchFolders(new File(path)); | |
System.out.println("Done."); | |
System.out.println("====================================="); | |
//Iterator it = v.iterator(); | |
Iterator it = al.iterator(); | |
while(it.hasNext()) { | |
Object o = it.next(); | |
System.out.println("[al] = " + o); | |
} | |
} | |
public static void searchFolders(File fo) { | |
if(fo.isDirectory()) { | |
String abspath = fo.getAbsolutePath(); | |
al.add(abspath); | |
System.out.println("Searching in..." + abspath); | |
String internalNames[] = fo.list(); | |
for(int i=0; i<internalNames.length; i++) { | |
searchFolders(new File(fo.getAbsolutePath() + "/" + internalNames[i])); | |
} | |
} else { | |
System.out.println("reached a file..." + fo.getName()); | |
} | |
// slut | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment