public static Object getProperty(Object obj, String propertyName)
    {
        if (obj == null)
            return null;
        try
        {
            BeanInfo info = Introspector.getBeanInfo(obj.getClass());
            PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
            for (int i = 0; i < descriptors.length; i++)
            {
                if (descriptors[i].getName().equals(propertyName))
                {
                    Method getter = descriptors[i].getReadMethod();
                    if (getter == null)
                        return null;
                    try {
                    return getter.invoke(obj);
                    } catch (Exception ex) {
                        System.out.println(descriptors[i].getName());
                        return null;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }