Please look at the indentation in your code (e.g. lines 56‑75); it is really inconsistent and it will make it much harder for you to find your way around your code.
Why are you using a tree map? Do you need the “K”s sorted? If not, declare all references to your map as
Map and instantiate what you have as a HashMap. You will notice you are getting the words in alphabetical order, which you wouldn't with a HashMap.
I don't understand the presence of the method starting line 19. Are you actually using it?
What does the array at the end of the code do?
You have all your methods static, and you are passing parameters from one to the other. But Java® is supposed to be an object language. You aren't creating any objects to encapsulate your data, otherwise you could have the Map as a field.
You don't appear to be closing the Scanner at the end of the code. Find out how to close it with
try‑with‑resources; then you will want all the reading code inside the body of the
try. I am not sure the
return in line 66 is doing you any good; if you fail to find a particular file, you will terminate the method.
I am not sure I understand the instructions about the ID for the file. Sorry.