集册 Java实例教程 获取Java Bean写入方法

获取Java Bean写入方法

欢马劈雪     最近更新时间:2020-01-02 10:19:05

450
获取Java Bean写入方法

/**

 * Archivists' Toolkit(TM) Copyright ? 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc.

 * All rights reserved.

 *

 * This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL)

 * version 1.0 (http://www.opensource.org/licenses/ecl1.php)

 *

 * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty

 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ECL license for more details about permissions and limitations.

 *

 *

 * Archivists' Toolkit(TM)

 * http://www.archiviststoolkit.org

 * info@archiviststoolkit.org

 *

 * @author Lee Mandell

 * Date: Mar 18, 2006

 * Time: 5:34:03 PM

 *//**from n o w  j a v a  . c o m**/

//package com.nowjava;

import java.beans.BeanInfo;

import java.beans.Introspector;

import java.beans.PropertyDescriptor;

import java.beans.IntrospectionException;

import java.lang.reflect.Method;


public class Main {

    public static void main(String[] argv) throws Exception {

        Class clazz = String.class;

        String propertyName = "nowjava.com";

        System.out.println(getWriteMethod(clazz, propertyName));

    }/**NowJava.com - 时代Java**/


    public static Method getWriteMethod(Class clazz, String propertyName)

            throws IntrospectionException {

        BeanInfo beanInfo = Introspector.getBeanInfo(clazz);

        PropertyDescriptor[] propertyDescriptors = beanInfo
展开阅读全文