XStream을 사용하여 파일의 사용자 객체를 저장하고 있습니다. 의 요소 내용에서 발견되었다 : (0x1a 유니 코드) : com.thoughtworks.xstream.io.StreamException : 유효하지 않은 XML 문자 StreamException : 잘못된 XML 문자 (유니 코드 : 0x1a)
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);
}
}
}
는 내가 예외가 다음과 같은 코드를 읽을하려고 할 때 문서.
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();
}
}
}
}
어떤 아이디어가 있습니까?
아마 관련 다음 해 http://stackoverflow.com/a/8427929/486504 –