Hi all,

I have employee class which I have 100 variables with getters and setters.
now I am passing employee object to processing method. Now I want to read all values in processing method.

Should I want to use getter for all member? Is there any way to achieve this.

pls any one help me

You can use the java.beans.Introspector class to get the BeanInfo for your bean. Then use the BeanInfo to get the PropertyDescriptors. That gives you an array of all the properties, from which you can call getReadMethod() to get each of the bean's get methods. You can invoke those methods to get all the property values.

Hi JamesCherrill,

Thanks for the reply
I have tried java.beans.Introspector with following code.In that I want to get the values of testBean object. How can I get that particular objects value. Could please help me.

    TestBean testBean = new TestBean();
    TestBean testBean1 = new TestBean();
    BeanInfo info = Introspector.getBeanInfo(TestBean.class);
    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {

pd.getReadMethod() gives you a Method object that represents a "get" method for the Bean. You can call the Method object's invoke method to execute the "get" method it represents and return the result

Thanks for your help .
now its working with following code


Dear JamesCherrill,
In the above code pd.getName() gives the list of bean variables in sorted order. Do we have any option for the same order in the class.
Thanks in advance.

Do you mean the order in which they are declared in the source code? No, I don't know any way to do that.