Question: Java Programming If one of the file names is a directory, add all the files inside it to the chain. If you want to get
Java Programming
If one of the file names is a directory, add all the files inside it to the chain. If you want to get even fancier, do this recursively.
I have this method:
private static void addFile(StringChain chain, String regex, Path file) {
try {
Scanner s1 = new Scanner(file);
s1.useDelimiter(regex);
chain.addItems(s1);
} catch (IOException ex) {
ex.printStackTrace();
}
}
And code within main method that adds files to string:
for (int a = 3; a < args.length; a++) {
String f1 = args[a];
addFile(chain, regex, Paths.get(f1));
}
How do recursively add all files inside file directory to chain? (Possibly using .walkFileTree)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
