[英]Tricky situation on Bean and Reflection
I want to read a flat file with contents like "Deepak,25,Singhal" and then populate the POJO dynamically. 我想读取一个平面文件,其中包含“ Deepak,25,Singhal”之类的内容,然后动态填充POJO。 I got the method object using reflection.
我得到了使用反射的方法对象。 I also created an instance using newInstance().
我还使用newInstance()创建了一个实例。
Problem I am stuck is method.invoke( obj, Object ..) ..Now how do I determine the Type of argument to be passed ! 我卡住的问题是method.invoke(obj,Object ..)..现在如何确定要传递的参数类型! From Method object how do I know that argument to be passed is int;
从Method对象,我怎么知道要传递的参数是int; so that I could convert String 25 to corresponding type so that method.invoke could be invoked !
这样我就可以将String 25转换为相应的类型,从而可以调用method.invoke!
在正则表达式的帮助下使用Java类来识别字符串,并将数字沙一般转换为相应的类型
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.