Here's a program: 

import java.util.*; 
import java.io.*; 

public class LabEight {
  public static void main(String[] args) throws Exception {
    ArrayList<String> los = LabEight.fun(new File("geah.txt")); 
    Map<String, Integer> lof = LabEight.countAllWords(los); 
    // https://docs.oracle.com/javase/8/docs/api/java/util/Map.html
    System.out.println( lof ); 
  }
  public static Map<String, Integer> countWord(Map<String, Integer> lof, String word) {
    if (lof.containsKey(word)) 
      lof.put(word, 1 + lof.get(word)); 
    else 
      lof.put(word, 1); 
    return lof; 
  }
  public static Map<String, Integer> countAllWords(ArrayList<String> los) {
    Map<String, Integer> lof = new HashMap<String, Integer>(); 
    for (String s : los) 
      lof = LabEight.countWord(lof, s); 
    return lof;
  }
  public static ArrayList<String> fun (File file) throws Exception { 
    // write your code here 
  }
}

If you run this on Green Eggs and Ham you get: 

Welcome to DrJava.  Working directory is C:\Users\cogli\Desktop
> run LabEight
{egss=1, they=1, fox=1, That=2, are.=1, Sam-I-am=4, house=1, goat...=1, not,=15, are=1, be!=2, 
not.=1, Sam=3, may.=1, on=7, goat!=1, Let=1, boat.=1, dark?=2, or=8, see.=3, boat!=1, like=44, 
,=1, them!=4, Do=1, not=48, Sam,=1, boat?=1, them=44, mot=1, goat.=1, will=21, them.=3, eat=22, 
them,=10, see!=1, Sam!=2, try=1, A=4, car.=1, I=71, Sam-I-am.=7, car,=1, Thank=2, could=11, 
say.=2, do=34, car!=3, me=4, Sam-I-am!=2, be.=1, may=3, d=1, be,=1, let=3, green=10, a=56, 
ANYWHERE!=1, Would=9, car?=1, ham=1, Try=3, Could=3, good=2, rain?=1, ham?=1, would=16, do!!=1, 
ham.=5, so=3, here=8, fox?=1, mouse.=5, house?=1, and=12, that=1, eggs=9, ham!=3, They=1, mouse?=1, 
house.=6, If=1, rain.=3, And=11, car=1, box.=6, mouse=2, fox.=5, tree?=1, In=1, Eat=2, woould=1, 
train?=1, dark!=2, ANHYWHERE!=1, So=1, goat?=1, box?=1, Say!=3, train,=1, train.=2, you?=2, Here=3, 
dark.=3, with=19, You=8, tree!=2, anywhere.=5, there?=1, you=13, train!=5, the=11, SO=1, in=40, 
Not=19, tree.=4, anywhere!=1, you!=1, am=3, there.=8, you,=10, ANd=1}


So all you have to do is: design method fun that turns a File into an ArrayList<String>.

Here's the text of the file for conformity: 

I am Sam

I am Sam
Sam I am

That Sam-I-am
That Sam-I-am!
I do not like
that Sam-I-am

Do you like
green eggs and ham

I do not like them,
Sam-I-am.
I do not like
green eggs and ham.

Would you like them
Here or there?

I would not like them
here or there.
I would not like them
anywhere.
I do not like
green eggs and ham.
I do not like them,
Sam-I-am

Would you like them
in a house?
Would you like them
with a mouse?

I do not like them
in a house.
I do not like them
with a mouse.
I do not like them
here or there.
I do not like them
anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.

Would you eat them
in a box?
Would you eat them
with a fox?

Not in a box.
Not with a fox.
Not in a house.
Not with a mouse.
I would not eat them here or there.
I would not eat them anywhere.
I would not eat green eggs and ham.
I do not like them, Sam-I-am.

Would you? Could you?
in a car?
Eat them! Eat them!
Here they are.

I woould not ,
could not,
in a car

You may like them.
You will see.
You may like them
in a tree?
d not in a tree.
I would not, could not in a tree.
Not in a car! You let me be.

I do not like them in a box.
I do not like them with a fox
I do not like them in a house
I do mot like them with a mouse
I do not like them here or there.
I do not like them anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.

A train! A train!
A train! A train!
Could you, would you
on a train?

Not on a train! Not in a tree!
Not in a car! Sam! Let me be!
I would not, could not, in a box.
I could not, would not, with a fox.
I will not eat them with a mouse
I will not eat them in a house.
I will not eat them here or there.
I will not eat them anywhere.
I do not like them, Sam-I-am.

Say!
In the dark?
Here in the dark!
Would you, could you, in the dark?

I would not, could not,
in the dark.

Would you, could you,
in the rain?

I would not, could not, in the rain.
Not in the dark. Not on a train,
Not in a car, Not in a tree.
I do not like them, Sam, you see.
Not in a house. Not in a box.
Not with a mouse. Not with a fox.
I will not eat them here or there.
I do not like them anywhere!

You do not like
green eggs and ham?

I do not
like them,
Sam-I-am.

Could you, would you,
with a goat?

I would not,
could not.
with a goat!

Would you, could you,
on a boat?

I could not, would not, on a boat.
I will not, will not, with a goat.
I will not eat them in the rain.
I will not eat them on a train.
Not in the dark! Not in a tree!
Not in a car! You let me be!
I do not like them in a box.
I do not like them with a fox.
I will not eat them in a house.
I do not like them with a mouse.
I do not like them here or there.
I do not like them ANYWHERE!

I do not like
green egss
and ham!

I do not like them,
Sam-I-am.

You do not like them.
SO you say.
Try them! Try them!
ANd you may.
Try them and you may I say.

Sam!
If you will let me be,
I will try them.
You will see.

Say!
I like green eggs and ham!
I do!! I like them, Sam-I-am!
And I would eat them in a boat!
And I would eat them with a goat...
And I will eat them in the rain.
And in the dark. And on a train.
And in a car. And in a tree.
They are so good so good you see!

So I will eat them in a box.
And I will eat them with a fox.
And I will eat them in a house.
And I will eat them with a mouse.
And I will eat them here and there.
Say! I will eat them ANHYWHERE!

I do so like
green eggs and ham!
Thank you!
Thank you,
Sam-I-am

--