I am using XStream to save the object of user in a file.
private void store() {
    XStream xStream = new XStream(new DomDriver("UTF-8"));
    xStream.setMode(XStream.XPATH_ABSOLUTE_REFERENCES);
    xStream.alias("configuration", Configuration.class);
    xStream.alias("user", User.class);
    synchronized (ConfigurationDAOImpl.class) {
        try {
            xStream.toXML(configuration, new FileOutputStream(filename.getFile()));
        } catch (IOException e) {
            throw new RuntimeException("Failed to write to " + filename, e);
        }
    }
}
When I am trying to read it by the following code I get an Exception: com.thoughtworks.xstream.io.StreamException: : An invalid XML character (Unicode: 0x1a) was found in the element content of the document.
private void lazyLoad() {
    synchronized (ConfigurationDAOImpl.class) {
        // Has the configuration been loaded
        if (configuration == null) {
            if (filename.exists()) {
                try {
                    XStream xStream = new XStream(new DomDriver("UTF-8"));
                    xStream.setMode(XStream.XPATH_ABSOLUTE_REFERENCES);
                    xStream.alias("configuration", Configuration.class);
                    xStream.alias("user", User.class);
                    configuration = (Configuration) xStream
                            .fromXML(filename.getInputStream());
                    LOGGER.debug("Loaded configuration from {}.", filename);
                } catch (Exception e) {
                    LOGGER.error("Failed to load configuration.", e);
                }
            } else {
                LOGGER.debug("{} does not exist.", filename);
                LOGGER.debug("Creating blank configuration.");
                configuration = new Configuration();
                configuration.setUsers(new ArrayList<User>());
                // and store it
                store();
            }
        }
    }
}
Any idea?
 
     
    