Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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) 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:\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

blur-text-image

Get Instant Access with AI-Powered 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