Take a .txt file for example.
For the homework question we have to make a program that takes the name of a file as a parameter and returns an integer, which contains the number of words in that file.
Here's what I've got so far
I think I've got the plan right, I just don't know how to add the .txt file, assign it to the method, and for the method to print how many lines there are.
Any help please? thank you!
For the homework question we have to make a program that takes the name of a file as a parameter and returns an integer, which contains the number of words in that file.
Here's what I've got so far
public static int wordAmount(String file)throws IOException
{
int x=0;
return x;
}
public static void main(String args[]) throws IOException
{
//add/find .txt file can call word wordAmount method
}
I think I've got the plan right, I just don't know how to add the .txt file, assign it to the method, and for the method to print how many lines there are.
Any help please? thank you!