Java/기본

Method 동적 호출

퓨어레드 2012. 4. 18. 12:21

메서드를 런타임시에 호출한다.

 

Class<?>[] argType = new Class[1];

argType[0] = G2ModelMap.class;
StringBuffer returnBuf = null;

try
{
	Method oneDataMethod = CommonGetOneDataBiz.class.getMethod (getName, argType);

	Object [] argData = new Object[1];

	argData[0] = rm;

	returnBuf = (StringBuffer) oneDataMethod.invoke (this, argData);
}
catch (Exception ex)
{
	ex.printStackTrace ();
}