How to save/load java classes in XML format with two code rows
Join the DZone community and get the full member experience.
Join For Free
JAXBReaderWriter is into ardulink.jar from www.ardulink.org JAXBReaderWriter manages correctly the character set. It uses explicity
UTF-8 and not the platform default. So you can use file created to and
from several systems and if you use non ASCII characters you can manage
strings correctly.
// if your JAXB annotated class is named Configuration you have just to write
JAXBReaderWriter readerWriter = new JAXBReaderWriter(Configuration.class);
// Now you can read it from a file
Configuration configuration = readerWriter.read(file);
// or save it to a stream
readerWriter.write(configuration, outputstream);
XML
Java (programming language)
Opinions expressed by DZone contributors are their own.
Comments