Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions