
ScriptScannerTest.java
By: a guest on Jun 14th, 2010 | syntax:
Java 5 | size: 1.08 KB | hits: 170 | expires: Never
import java.io.IOException;
import java.io.File;
public class ScriptScannerTest {
public static void main(String[] args) throws IOException {
File startPath = new File("C:\\Users\\Gary\\Desktop\\Trek\\");
System.out.println("File,Line,Keyword,Value");
visitAllDirsAndFiles(startPath);
}
private static void visitAllDirsAndFiles(File dir) throws IOException {
// Process all files and directories under dir
// Thanks to: http://www.exampledepot.com/egs/java.io/TraverseTree.html
if (!dir.isDirectory()) {
// scan this file
String filePath = dir.getAbsolutePath();
if (filePath.matches(".*txt$")) {
String contents = ScriptScanner.getFileContents(filePath);
contents = ScriptScanner.stripFileContents(contents);
ScriptScanner.scanFor(filePath, contents, "heading", "bearing", "mark", "range", "sector");
}
}
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
visitAllDirsAndFiles(new File(dir, children[i]));
}
}
}
}