I can't figure out, how to use getDeclaredMethods() (reflection) if the user chooses the file from GUI.
inFile is File type, and I get it when the user chooses the file from GUI.
public static void read_file_methods () {
Class in_class= inFile.getClass();
Method[] methods = in_class.getDeclaredMethods();
....
}
I can't get the input file's class, just object's, but how do I get the object from input? I can't use MyProgram m = new MyProgram(); ... and don't know how to use .newInstance() to be working.
"I'd like to get the declared methods from the input file, and then list them in my GUI. The user can choose a txt or java file, when he/she did, the program will get the methods from this (if there are any) and list them on a jList. Works if I know the Object's name, but not if it comes later."