This discussion is archived
6 Replies Latest reply: Aug 3, 2009 2:30 AM by 796440 RSS

How do I create an object from a filename?

800439 Newbie
Currently Being Moderated
I'm traversing directories and storing a list of files in a File array. Then I traverse the array looking at the extension of the file. If it is .java then I would like to instantiate it as a class so that I may pass the new object to another function which will examine its methods. I've tried Class.forName(file.getCanonicalPath()) and it throws a ClassNotFound exception. How can I create an object from a valid filename, please?