Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an application program that will read a large text file (the input file, must contain plain ordinary English text of at least 10000 words),

Write an application program that will read a large text file (the input file, must contain plain ordinary English text of at least 10000 words), count the number of occurrences of each word in the file, and then write the results in the output file, sorted by the frequency count. At its invocation, the program shall accept two command line parameters:
a. The input filename: this file must be a .txt file,
b. The output filename.
These parameters must appear in the command line in the same order as shown in the following
example: Prompt>java ProgName Hamlet.txt HamletWordCount.txt
As you noticed from the above example, "ProgName" is the name of your program; followed by the input .txt file name; and then the output filename.
Your program shall read the command line and have all the parameters in the args string of the main method. These strings must be processed as follows:
1. If the number of parameters is less than 2, it should print an error message and exit.
2. Read the first parameter and check if the input file name exists on disk. If the file does not exist, print an error message and exit.
3. Read the second parameter and create this output file, checking for any errors. If errors occur, print an error message and exit. 4. Proceed in processing the input file according to a plan that you should have designed beforehand. Your plan must be well documented and submitted with your program. Your program must also be fully documented and commented.
5. When the end of the input file is reached, close it.
6. When you finish writing to the output file, close it; print a success message and exit.
7. Important: Test your program thoroughly.

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