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
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