Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement