Java XML JAXB Unserialize loadXML(Class type, File sourceFile)

Here you can find the source of loadXML(Class type, File sourceFile)

Description

load XML

License

LGPL

Declaration

public static <T> T loadXML(Class<T> type, File sourceFile) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

import java.io.File;

public class Main {
    public static <T> T loadXML(Class<T> type, File sourceFile) {
        try {/*from   w  ww  .  j a  v  a2 s  . c  om*/
            JAXBContext context = JAXBContext.newInstance(type);
            return (T) context.createUnmarshaller().unmarshal(sourceFile);
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. load(File f, Class... args)
  2. load(final String xml, final Class clazz)
  3. load(InputStream input, Class type)
  4. loadObject(Class typeClass, URL path)
  5. loadObject(Path path, Class clazz)
  6. loadXml(File file, Class requireType)
  7. loadXML(Object object, String fileNamePath)
  8. loadXMLFromString(Object object, String line)
  9. parse(final Class clazz, final InputStream inputStream)