Java Program – to count a number of words in a file.

First, save the content in a text file with the same name that you enter in a program.
For this example, a text file saved with the name javaCode.txt

javaCode.txt

Welcome to Simple2Code.
Let Start
first tutorial
second Program

Output: