集册 Java实例教程 有明确的Bean信息

有明确的Bean信息

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

461
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
有明确的Bean信息
/** n o w  j a v a  . c o m 提 供 **/

//package com.nowjava;

import java.beans.Introspector;


public class Main {

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

        Class clazz = String.class;

        System.out.println(hasExplicitBeanInfo(clazz));

    }


    public static boolean hasExplicitBeanInfo(Class clazz) {

        String className = clazz.getName();

        int indx = className.lastIndexOf('.');

        className = className.substring(indx + 1);


        String[] paths = Introspector.getBeanInfoSearchPath();

        for (String path : paths) {

            String s = path + '.' + className + "BeanInfo"; // NOI18N

            try {

                // test if such class exists

                Class.forName(s);

                return true;/**来 自 时代Java - N
展开阅读全文