Java XML JAXB Unserialize load(File f, Class... args)

Here you can find the source of load(File f, Class... args)

Description

load

License

Apache License

Declaration

public static <T> T load(File f, Class... args) throws Exception 

Method Source Code


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

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.Unmarshaller;

public class Main {
    public static <T> T load(File f, Class... args) throws Exception {
        return load(new FileInputStream(f), args);
    }/*w w  w  . j  a  va  2  s  .  c om*/

    public static <T> T load(InputStream is, Class... args) throws Exception {
        JAXBContext jaxb = JAXBContext.newInstance(args);
        Unmarshaller unmarshaller = jaxb.createUnmarshaller();
        return (T) unmarshaller.unmarshal(is);
    }
}

Related

  1. inputStreamToObject(InputStream xml, Class clazz)
  2. inputStreamToObject(String xml, Class clazz, Class[] classes)
  3. load(Class clazz, InputStream is)
  4. load(Class clazz, InputStream is)
  5. load(final String xml, final Class clazz)
  6. load(InputStream input, Class type)
  7. loadObject(Class typeClass, URL path)
  8. loadObject(Path path, Class clazz)