object数组转实体类

{

                Object[] objects = (Object[]) iterator.next();
                Object obj = objectToJavaBean(objects,FormVo.class);
                hrfv = (FormVo) obj;

}

public static Object objectToJavaBean(Object[] objects,Class type){
        Object object=null;
        try {
            object=type.newInstance();
            for(int i=0;i                 String methodname="set"+type.getDeclaredFields()[i].getName().substring(0,1).toUpperCase()+type.getDeclaredFields()[i].getName().substring(1);
                    Method setmethod=type.getDeclaredMethod(methodname,new Class[]{type.getDeclaredFields()[i].getType()});
                    setmethod.invoke(object,objects[i]);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return object;
    }

你可能感兴趣的:(object数组转实体类)