public final class XmlUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends XmlSerializable> |
loadObject(String filePath,
Class<T> clazz)
Loads the given XML file into a corresponding serializable Java object.
|
static String |
loadXML(String filePath)
Loads an XML file into a String.
|
static String |
objectToXml(XmlSerializable object)
Converts a serializable Java object into XML format as a String.
|
static void |
saveObject(XmlSerializable object,
String filePath)
Saves a serializable Java object to an XML file at the given location.
|
static void |
saveXML(String xml,
String filePath)
Saves an XML String to a file at the given location.
|
static <T extends XmlSerializable> |
xmlToObject(String xml,
Class<T> clazz)
Converts an XML String into a serializable Java object.
|
public static String objectToXml(XmlSerializable object)
object
- the object to convert to XMLInternalServerErrorException
- if an unexpected error
occurredpublic static <T extends XmlSerializable> T xmlToObject(String xml, Class<T> clazz)
xml
- the string to convert into an objectclazz
- the class of the serializable objectInternalServerErrorException
- if an unexpected error
occurredpublic static void saveXML(String xml, String filePath)
xml
- the XML StringfilePath
- the path where to save the XML fileInternalServerErrorException
- if an unexpected error
occurredpublic static String loadXML(String filePath)
filePath
- the path of the XML file to loadInternalServerErrorException
- if an unexpected error
occurredpublic static void saveObject(XmlSerializable object, String filePath)
object
- the object to save as XMLfilePath
- the path where to save the XML fileInternalServerErrorException
- if an unexpected error
occurredpublic static <T extends XmlSerializable> T loadObject(String filePath, Class<T> clazz)
filePath
- path of the file to loadclazz
- class of the target Java objectInternalServerErrorException
- if an unexpected error
occurredCopyright © 2009–2020 Waarp. All rights reserved.