Here you can find the source of loadObject(Class
public static <T> T loadObject(Class<T> typeClass, URL path)
//package com.java2s; //License from project: Artistic License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.File; import java.net.URISyntaxException; import java.net.URL; public class Main { public static <T> T loadObject(Class<T> typeClass, URL path) { T object = null;//from ww w .j a v a2 s .c o m try { File file = new File(path.toURI()); JAXBContext jaxbContext = JAXBContext.newInstance(typeClass); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); object = (T) jaxbUnmarshaller.unmarshal(file); } catch (JAXBException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } return object; } }