1

What I'm trying to do is code a method that takes any kind of text input like

"words.text"

What I imagined it would look like would be

public static wordcount(File afile){....}

I want the method to be called such as

wordcount("words.txt");

I tried looking for the answer but couldn't find it. How do I do this?

1 Answers1

1

Make the method with the following signature

public static void wordCount(String fileName){...}

Then inside the mthod use the string to make a File object.

public static void wordCount(String fileName){
    File aFile = new File(fileName);
}
Wyatt Lowery
  • 513
  • 1
  • 7
  • 21