Traverse directory structure
Hi does anyone know how I would traverse a directory structure?Problem:I need to search through a selected directory of txt files searching for a certain string. I also need to be able to search each and every sub directory and so on.
[262 byte] By [
ljcaseya] at [2007-10-1 7:29:27]

yes.
Use java.io.File to traverse files. You could do this depth-first or breadth-first using recursion or use an iterative approach.
For each file you visit, open a BufferedReader and read line by line using String.indexOf(searchString). This assumes the certain string cannot span lines.
Good luck