Write a program to open a text file (java.txt), and count howmany words are in the file. A word is considered character(s)flanked by spaces, and it is not necessary to strip off thepunctuation characters. The file name should be given as anargument to the program. Print a message to the screen to indicatehow many words the file contains. Also, print out a sorted list ofunique words followed by the number of occurrences of each word inthe text.
Expert Answer
Answer to Write a program to open a text file (java.txt), and count how many words are in the file. A word is considered character…