Java XML JAXB String to Object fromXML(Class clazz, InputStream is)

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

Description

from XML

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
public static <T> T fromXML(Class<T> clazz, InputStream is) throws JAXBException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.InputStream;

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

import javax.xml.bind.Unmarshaller;

public class Main {

    @SuppressWarnings("unchecked")
    public static <T> T fromXML(Class<T> clazz, InputStream is) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(clazz);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return (T) unmarshaller.unmarshal(is);
    }/*from ww w  .j ava 2s . co m*/
}

Related

  1. createObject(String xml, Object type)
  2. fromFile(Class jaxbClass, String fileName)
  3. fromStream(Class jaxbClass, InputStream is)
  4. fromStringToObject(String xmlString, Class xmlObjClass)
  5. fromXml(@SuppressWarnings("rawtypes") Class clazz, String stringXml)
  6. fromXml(Class tClass, InputStream inputStream)
  7. fromXml(File xmlPath, Class type)
  8. fromXML(final byte[] data, final Class type)
  9. fromXml(final Reader reader, final Class dtoClass)