Java toStrting method for recursive debugging info

I am looking for a short working program written in java language that will output (write to String which it would return) all property names and values of the passed parameter if value is string or primitives or wrappers around primitives like Integer. If the value is another property then it recursively does the same with this property and so on. It must also output dynamically added properties (not defined in the class). The output should be in format like;

class_name {
   another_class_name {

public String outputpit(Class obj)
Who is Participating?
jV247Connect With a Mentor Commented:
This solution is generic to Java. Basically, use the Apache commons-lang:

Inside it, you'd see a ToStringBuilder, documented in:
marklorenzConnect With a Mentor Commented:
The easiest way is to define a toString() method which contains the information you want (of course, you can call it any name, but toString() is the expected method).
zenguruAuthor Commented:
this is not a solution at all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.