Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Java application that searches a set of files for a particular word and

ID: 3574863 • Letter: C

Question

Create a Java application that searches a set of files for a particular word and displays the file name along with line number(s) where the word appears in the file. The data files used for input to this application are simple ASCII text files. Use the following artifacts as a guide.

Program Specifications

Design a program with the following specifications:

Program Usage:   java FileParser

The program should use a JOptionPane to prompt the user for the name of a file. This file contains the names and extensions of the input data files.

If the file input by the user does not exist or an I/O error occurs while processing it, an error message is displayed and execution halts.

If a data file named in the input file is not found, an error message is displayed and processing continues.

The input data files are plain ASCII text files containing varying numbers of words and lines.

If an I/O error occurs while processing a data file, an error message is displayed and processing continues.

Each data file is read sequentially and each line within the file is broken into individual words (parsed).

A FileObj object is created for each file and is used by the application to represent the file.

Each unique word in the file is used to create a Word object. Duplicate words cause the line number collection for the word to be updated.

Each FileObj object contains a hash map of Word objects.

Punctuation and case within the text should be ignored.

After the data files are processed, summary information should be displayed to standard out.

When the user enters in word other than the “exit” string, the application should search each FileObj object for the string.

If the string is found among the words in the file, the file name along with the corresponding line number(s) are displayed on standard output.

If no match is found in any file, the message “<STRING> not found in any file” should be displayed.

Program output should be neat, clear, and adequately spaced for readability.

Program Implementation

Implement the program as a Java application using a single compilation unit with the following components: a FileParser class, a FileObj class, a Word class, and a MyMap class.

Name the file FileParser.java.

Use Javadoc for external documentation.

For internal documentation, use plenty of comments throughout the program.

For grading, submit a copy of the source code and the corresponding Javadoc files.

Explanation / Answer

Hope this code helps you: