Properties class has very nice methods storeToXml and loadFromXml. But store adds header, so xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="key">value</entry>
</properties>
I don’t want to have this header, because i store it in database to make it xpath serchable. And also i want to load in to Properties object. Have anyone good ideas? Thanks
Neither XPath nor
Properties.loadFromXml()care for the header. So this should work as it is.If it’s really a problem, then write the result to a
StringWriterorByteArrayOutputStreamand remove anything before<properties>. But that might actually cause errors loading the XML since the doctype is now missing.