Java XML JAXB Unmarshaller unmarshalFromReader(Reader reader, Class c)

Here you can find the source of unmarshalFromReader(Reader reader, Class c)

Description

unmarshal From Reader

License

Open Source License

Declaration

public static Object unmarshalFromReader(Reader reader, Class<?> c) throws JAXBException 

Method Source Code


//package com.java2s;
//## The MIT License

import java.io.Reader;

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

import javax.xml.bind.Unmarshaller;

public class Main {
    public static Object unmarshalFromReader(Reader reader, Class<?> c) throws JAXBException {
        Object result = null;/*from ww  w. j a v a  2  s . c  o m*/

        JAXBContext jc = JAXBContext.newInstance(c);
        Unmarshaller um = jc.createUnmarshaller();
        result = um.unmarshal(reader);

        return result;
    }

    public static Object unmarshal(org.w3c.dom.Element elem, Class<?> c) throws JAXBException {
        Object result = null;

        JAXBContext jc = JAXBContext.newInstance(c);
        Unmarshaller um = jc.createUnmarshaller();
        result = um.unmarshal(elem);

        return result;
    }
}

Related

  1. unmarshal(String xml, Class clazz)
  2. unmarshal(String xml, Class clazz)
  3. unmarshal(T entity)
  4. unmarshalByContent(Class clazz, String xmlContent)
  5. unmarshalDOMElement(byte[] input)
  6. unmarshalFromString(Class clz, String input)
  7. unmarshalFromXml(Class clazz, String xml)
  8. unmarshalFromXml(final String xml, Class destinationClass)
  9. unmarshalInstance(final String data, final Class expectedType)