Hi, sorry to bother you guys again, but as above. Any ways to print out everything(every lines of code) that is on another class?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi, sorry to bother you guys again, but as above. Any ways to print out everything(every lines of code) that is on another class?
Last edited by javanub:(; May 13th, 2010 at 12:57 AM.
Not possible directly.
But any way if that class is providing all its code as string through toString method then you can print.
You could print the method signatures, but not the actual method content. If you want to print the whole file you need to make sure its available as a .java file and that you can read it, load the file in and just read it line by line and print it, but I take it that's not what you want.
Any chance you can narrow down to what exactly it is you want?
// Json
Either have the .java source file available, or a handy Java Bytecode decompiler. Note that I think due to what is actually available in compiled form (variable names, code logic, any other code obfuscation that might be implemented by the compiler), you won't get back the exact code that was originally written, and you definately won't get back any comment information (Javadocs are questionable)
okay.. what i wanna do is to pass in what is inside another class(the actual content) or or a method of the another class(the method's content) into a string. then use the string to upload to the server using my client api.
Last edited by javanub:(; May 13th, 2010 at 09:17 PM.
You would really need to have the .java file for the source available for this or as helloworld says, use a decompiler. Getting method content can not be done through reflection. You can however invoke a method and get the return value.
// Json
thanks guys, anyway this problem is solved
How did you solve it if I may ask?
// Json
reflection