Question
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
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) is a valid, readable directory c) the directory does not exist. If there is a violation of these requirements, the program prints an error message and stops. The program must read the files in in parallel using multiple threads and create an index of every token (a sequence of characters delineated by white space) in the input files: the token, the file name in which it occurs and the line number or offset in the file must all be output to a file in . All file names and line numbers associated with a token must be output before outputting the next token and its related information. Suppose the files data1 and data2 are files in the folder C:\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:\PA2 Map\data\file2.txt:2 2 four: C:\PA2 Map\data\file1.txt:2 C:\PA2 Map\data\file1.txt:3 C:\PA2 Map\data\file2.txt:2 one: C:\PA2 Map\data\file1.txt:1 C:\PA2 Map\data\file2.txt:1 seven: C:\PA2 Map\data\file2.txt:2 two: C:\PA2 Map\data\file1.txt:1 C:\PA2 Map\data\file2.txt:1 C:\PA2 Map\data\file2.txt:2 three: C:\PA2 Map\data\file1.txt:2 C:\PA2 Map\data\file2.txt:1 C:\PA2 Map\data\file2.txt:2 five: C:\PA2 Map\data\file2.txt:2 eight: C:\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 to Expert-Tailored 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