Text Analyzer
Single File Programming Question
Problem Statement
Richard is developing a text analysis program to help with document processing. The program should prompt the user to input multi-line content, write this content into a file named textAnalyze.txt, and then read the content from the same file to calculate and display the total number of words present.
Your task is to help Richard write the program that performs all of these steps using file handling in Java.
Input:
format :The input consists of the content for the textAnalyze.txt file as a multi-line string.
The user should enter "END" on a new line to indicate the end of input.
Output:
format :The output prints "No of words: " followed by an integer representing the number of words in the entered string.
Refer to the sample output for formatting specifications.
Code constraints : The given testcases fall under the following constraints:
1 ≤ Number of lines ≤ 5
1 ≤ Number of characters in a line ≤ 100
Sample test cases :
Input 1:
This is a sample text file. It contains multiple lines. Each line is counted separately.
END
Output 1 :
No of words: 15
Input 2 :
Hello world! This is a test.
END
Output 2 :
No of words: 6