Question
Use Callables ? Use Thread pools ? Use Futures ? Design and develop a program that accepts the name of a directory that contains a
Use Callables ?
Use Thread pools ?
Use Futures ?
Design and develop a program that accepts the name of a directory that contains a set of text-only files. The program must be executable as below. ?java PA2
?The program ensures the following: ?
a) there are two parameters to the main method ?
b)
c) the directory
If there is a violation of these requirements, the program prints an error message and stops.
The program must read the files in
Suppose the files data1 and data2 are files in the folder C:\Classes\ICS 440\PA2 Map\data. The file data1 contains the following three lines.
one two
three four
four
And data2 contains the following three lines.
one two three
two three four five six seven
eight
An output would be as follows. (The order of the tokens is unimportant.)
six: C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
1
four: C:\Classes\ICS 440\PA2 Map\data\file1.txt:2 C:\Classes\ICS 440\PA2
Map\data\file1.txt:3 C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
one: C:\Classes\ICS 440\PA2 Map\data\file1.txt:1 C:\Classes\ICS 440\PA2
Map\data\file2.txt:1
seven: C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
two: C:\Classes\ICS 440\PA2 Map\data\file1.txt:1 C:\Classes\ICS 440\PA2
Map\data\file2.txt:1 C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
three: C:\Classes\ICS 440\PA2 Map\data\file1.txt:2 C:\Classes\ICS 440\PA2
Map\data\file2.txt:1 C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
five: C:\Classes\ICS 440\PA2 Map\data\file2.txt:2
eight: C:\Classes\ICS 440\PA2 Map\data\file2.txt:3
It is fine to output just the file name relative to the folder as opposed to the absolute path name.
Use a combination of thread pools, Callables, and Futures. All files must be processed in parallel to update a concurrent map implementation from java.util.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started