What I mean by this, is opening a file with a Java code in it as a class, not as a file. So basically I want to:
-> Open a pure text file in a self written Java application (.txt/.log/.java)
-> Recognize class(es) in the file, for example:
public class TestExample {
private String example;
public String getExample() {
return example;
}
}
I will open this in a hand-written program. Instead of recognizing the text in the file as a String or as pure text, it will find the class TestExample in it. Then it will save this as a Class.
-> Use the Reflection API on the class
-> Get fields, methods, etc from file and display them
Would this be possible?
Yes, it is possible.
Have a look at this example.
http://weblogs.java.net/blog/malenkov/archive/2008/12/how_to_compile.html
Knowing how to find and read files (which is really simple), you can then use the code shown, especially
to compile the code and then call it using reflection.