So what I am trying to do is
- Take user input (that is supposed to be a file name) and check if that file exists in my current work folder. ( I DONT NEED HELP HERE, this is under control)
- If the file exists, I want to create an instance of that file. (I wanna do this so I can use reflections and check if the file is a particular interface, and check the constructor.
So for testing my program, i created an instance of a existing file like this:
File tempFile = new File("/CURRENTFOLDER/" + file + ".java");
//with the user input tempFile = Test1.
if(tempFile.exists()){
Test1 test1 = new Test1();
Class<?> test1_class = test1.getClass();
but what i really wanna do is something like this:
File tempFile = new File("CURRENTFOLDER" + file + ".java");
if(tempFile.exists()){
//Test1 test1 = new Test1();
//Class<?> test1_class = test1.getClass();
tempFile instance_of_tempFile = new tempFile();
Class<?> ? test_class = instance_of_tempFile.getClass();
I know you can't write tempFile instance_of_tempFile = new tempFile();
, but just included that so you understand what I'm trying to do.