Java XML JAXB Unmarshaller unmarshal(InputStream is, Class clazz)

Here you can find the source of unmarshal(InputStream is, Class clazz)

Description

unmarshal

License

Apache License

Declaration

public static Object unmarshal(InputStream is, Class<?> clazz) 

Method Source Code


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

import java.io.InputStream;

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

import javax.xml.bind.Unmarshaller;

public class Main {
    public static Object unmarshal(InputStream is, Class<?> clazz) {
        try {/*from   ww w. ja v a2 s .  c  o  m*/
            JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            Object object = unmarshaller.unmarshal(is);

            return object;
        } catch (JAXBException e) {
            throw new RuntimeException("Error unmarshalling object", e);
        }
    }
}

Related

  1. unmarshal(InputSource inputSource, Class clazz)
  2. unmarshal(InputStream content, Class expectedType)
  3. unmarshal(InputStream in, Class... boundClasses)
  4. unmarshal(InputStream inputStream, Class entityClass)
  5. unmarshal(InputStream inputStream, Class type)
  6. unmarshal(InputStream stream, Class clazz)
  7. unmarshal(JAXBContext context, Class clazz, String source)
  8. unmarshal(JAXBContext jaxbContext, XMLStreamReader xmlStreamReader)
  9. unmarshal(org.w3c.dom.Element elem, Class c)