android 反序列化 代码
private void createFileXML() {
File file = new File(Environment.getExternalStorageDirectory(),"file.xml");
try {
file.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
XmlSerializer serializer = Xml.newSerializer();
serializer.setOutput(fileOutputStream, "utf-8");
serializer.startDocument("UTF-8", true);
serializer.startTag(null, "xml");
serializer.attribute(null, "id", "wangsong");
serializer.startTag(null, "name");
serializer.text("哈哈哈");
serializer.endTag(null, "name");
serializer.endTag(null, "xml");
serializer.endDocument();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
工具类 jackson-all-1.9.2.jar