📄 methodutil.java
字号:
package hong.javanet.util;
import java.lang.reflect.*;
/**
*
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author 洪桃李
* @version 2.0
*/
public class MethodUtil {
public static Object invoke(Object target,String methodName) {
try {
Method method = target.getClass().getMethod(methodName, new Class[0]);
return method.invoke(target,new Object[0]);
} catch (Throwable ex) {
throw ExceptionUtil.wrapException(ex);
}
}
public static Object invoke(Object target,String methodName,String parameter) {
try {
Method method = target.getClass().getMethod(methodName,
new Class[] {String.class});
return method.invoke(target,new Object[]{parameter});
} catch (Throwable ex) {
throw ExceptionUtil.wrapException(ex);
}
}
public static Object invoke(Object target,String methodName,
Class[] paramClasses, Object[] parameters) {
try {
Method method = target.getClass().getMethod(methodName, paramClasses);
return method.invoke(target,parameters);
} catch (Throwable ex) {
throw ExceptionUtil.wrapException(ex);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -