Advertisement
Guest User

ScriptScannerTest.java

a guest
Jun 14th, 2010
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.08 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.File;
  3.  
  4. public class ScriptScannerTest {
  5.  
  6.     public static void main(String[] args) throws IOException {
  7.         File startPath = new File("C:\\Users\\Gary\\Desktop\\Trek\\");
  8.         System.out.println("File,Line,Keyword,Value");
  9.         visitAllDirsAndFiles(startPath);
  10.     }
  11.      
  12.     private static void visitAllDirsAndFiles(File dir) throws IOException {
  13.         // Process all files and directories under dir
  14.         // Thanks to: http://www.exampledepot.com/egs/java.io/TraverseTree.html
  15.         if (!dir.isDirectory()) {
  16.             // scan this file
  17.             String filePath = dir.getAbsolutePath();
  18.             if (filePath.matches(".*txt$")) {
  19.                 String contents = ScriptScanner.getFileContents(filePath);
  20.                 contents = ScriptScanner.stripFileContents(contents);
  21.                 ScriptScanner.scanFor(filePath, contents, "heading", "bearing", "mark", "range", "sector");
  22.             }
  23.         }
  24.  
  25.         if (dir.isDirectory()) {
  26.             String[] children = dir.list();
  27.             for (int i=0; i<children.length; i++) {
  28.                 visitAllDirsAndFiles(new File(dir, children[i]));
  29.             }
  30.         }
  31.     }
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement