How to load a .kt file from src folder?

Within the same project I am trying to get all the files that contain enum. I don’t know the file names that contain this.

I normally could do: .getClass().getResourceAsStream("file.txt");

but in this case I’m not sure how to do this.

Answer

Here is the way you can get the classes inside your application. Can you find all classes in a package using reflection?

It requires this library https://github.com/ronmamo/reflections

Once you get all classes
you can iterate through all of them and use this solution.
Checking if a class is java.lang.Enum

There are a few caveats when trying to figure out if a class is truly an enum depending on where it exists. The accepted answer has 3 solutions to deal with the caveats.

Note this is in Java but should be easily convertible.