I've got this java program which is currently programmed to take in a filename as an argument from command line, open it and then read it. I want to configure it so I can pass it a directory name and the program will execute on the files in the directory. Not really sure how to go about it. This is my code currently:
static XMLInputFactory factory = XMLInputFactory.newInstance();
XMLEventReader reader = null;
XMLEventFactory eventFactory = null;
public XMLTrimmer(File ifp) throws XMLStreamException, FileNotFoundException {
this(new FileInputStream(ifp));
}
public XMLTrimmer(InputStream str) throws XMLStreamException, FileNotFoundException {
try {
reader = factory.createXMLEventReader(str);
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
In main it goes like this:
public static void main(String args[]) throws IOException, XMLStreamException {
File readFile = new File(args[0]);
XMLTrimmer xr = new XMLTrimmer(readFile);
please let me know, any help is appreciated.