Question: Lab Exercise 08.1 Searchable Text File USE JAVA The purpose of this program is to create a class named Searcher that inherits the necessary functionality

Lab Exercise 08.1

Searchable Text File

USE JAVA

The purpose of this program is to create a class named Searcher that inherits the necessary functionality of a text file and adds functionality to search and count occurrences.

The search method will read a text file, read a string from the user, search the text file for all occurrences of the string and print the string along with the number of occurrences found.

The class will:

Inherit the File class

Use (as an attribute) the Scanner class

Receive the text file name in the class constructor (file will be longer than 1000 words)

The search method will:

Receive the search-string (16 characters or fewer)

Open the text file

Read the input file, searching for the search-string while reading (file will be longer than 1000 words)

Count occurrences of the text string

Close the text file

Print the search-string and the number of occurrences

Ex: xYz was found 11 times in data.txt

Remember to test thoroughly, including

No matches

One match

Many matches

The matching must be case-sensitive.

Remember that a text string can span two or more words.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!