Java XML JAXB Unserialize load(InputStream input, Class type)

Here you can find the source of load(InputStream input, Class type)

Description

load

License

Apache License

Declaration

public static <T extends Object> T load(InputStream input, Class<T> type) throws IOException 

Method Source Code


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

import java.io.IOException;
import java.io.InputStream;

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

import javax.xml.bind.Unmarshaller;

public class Main {
    public static <T extends Object> T load(InputStream input, Class<T> type) throws IOException {
        try {//from ww w  .ja va  2s. c o m
            JAXBContext context = JAXBContext.newInstance(type);
            Unmarshaller um = context.createUnmarshaller();
            return (T) um.unmarshal(input);
        } catch (JAXBException ex) {
            throw new IOException("Exception thrown while deserializing stream", ex);
        }
    }
}

Related

  1. inputStreamToObject(String xml, Class clazz, Class[] classes)
  2. load(Class clazz, InputStream is)
  3. load(Class clazz, InputStream is)
  4. load(File f, Class... args)
  5. load(final String xml, final Class clazz)
  6. loadObject(Class typeClass, URL path)
  7. loadObject(Path path, Class clazz)
  8. loadXML(Class type, File sourceFile)
  9. loadXml(File file, Class requireType)