Question: Objective: More practice reading text files and working with String data. Implement a java program that uses the JFileChooser dialog to let the user specify

Objective: More practice reading text files and working with String data.

Implement a java program that uses the JFileChooser dialog to let the user specify a text file on

the system. The program should then open and read the file line by line. The program should

then print a summary report of the file to the console (screen). The summary report should

contain the following:

The name of the file the user chose to process

Number of lines in the file

Number of words in the file

Number of characters in the file

Suggested process:

Open the file after the user specifies it with JFileChooser. Read each line one at a time keeping

track of how many lines you read. As you read each line, count how many words there are. (A

simple way to do is to count the number of spaces separating the words. N spaces suggests

that there are N + 1 word on the line assuming no doubled spaces. You can also use the split

function to return an array of the words and the length of the array is how many words there are.

This works better than just counting the spaces...) Finally, as you read each line use the String

length property to count how many characters are in the line and keep track of the total length of

the file.

Get a screenshot that shows the JFileChooser running.

Get a screenshot that shows your output stats for a successful program run.

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 Programming Questions!