T
- the typed parameters to convert to and from XMLpublic class XmlUtils<T> extends Object
Constructor and Description |
---|
XmlUtils()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
T |
readXmlFromFile(File file,
Class<T> clazz)
Reads and xml file using JAXB.
|
T |
readXmlFromString(String xml,
Class<T> clazz)
Reads the XML from a string
|
void |
writeXmlToFile(File file,
T obj)
Writes a JAXB instance object to a file.
|
String |
writeXmlToString(T obj)
Writes a JAXB instance object to a String.
|
public T readXmlFromFile(File file, Class<T> clazz) throws IOException
file
- the file to read.clazz
- the JAXBContext class with XMLRootElement.IOException
- if any failure loading or passing the file.public void writeXmlToFile(File file, T obj) throws IOException
file
- the file to write to.obj
- the object instance of type <T>IOException
- if any failure writing the file.public T readXmlFromString(String xml, Class<T> clazz) throws IOException
xml
- the XML stringclazz
- the JAXBContext class with XMLRootElement.IOException
- if any failure reading the Stringpublic String writeXmlToString(T obj) throws IOException
obj
- the object instance of type <T>IOException
- if any failure writing to the String.Copyright © 2016. All rights reserved.