Get “Class” object from generic type T

后端 未结 6 1835

I want to make generic function that return Object representation of XML document (using JAXB). I need to pass \"class\" object to JAXBContext constructor, but how I can get it

6条回答
  •  忘掉有多难
    2021-02-19 16:59

    public class XYZ {
        ...
        private Class tClass;    
        ...
        public  readXmlToObject(String xmlFileName) {
           JAXBContext context = JAXBContext.newInstance(tClass);
           ...
        }
        ...
    } 
    

提交回复
热议问题