Last active
December 30, 2015 07:29
-
-
Save pete2786/7796676 to your computer and use it in GitHub Desktop.
Recursive file walker code, original from http://stackoverflow.com/questions/2056221/recursively-list-files-in-java
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
public class Filewalker { | |
public void walk( String path ) { | |
File root = new File( path ); | |
File[] list = root.listFiles(); | |
if (list == null) return; | |
for ( File f : list ) { | |
if ( f.isDirectory() ) { | |
// Might want to do something here, set a variable to track which folder | |
// you are currently in or something to use later for storing in the meta data tables | |
walk( f.getAbsolutePath() ); | |
} | |
else { | |
//Grab the file name to pass to the function for inserting report name into table, may also | |
// want to run it through a santizer to convert stuff like the %256 -> : | |
String report_name = f.getName(); | |
//Pass the file path to the parser, might need to just use the the ReadXMLFile_report.java | |
// class, instantiate that and pass the report name and file path to be parsed. | |
saxParser.parse(f.getAbsoluteFile()); | |
} | |
} | |
} | |
public static void main(String[] args) { | |
String webcatalog_root = "c:\\" // TODO: Change to a command line arg or setting | |
Filewalker fw = new Filewalker(); | |
fw.walk(webcatalog_root); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment