标签:
1 public static String ToXmlText(Object obj)throws Exception { 2 ByteArrayOutputStream bos= new ByteArrayOutputStream(); 3 XMLEncoder encoder = new XMLEncoder(bos); 4 encoder.writeObject(obj); 5 encoder.flush(); 6 encoder.close(); 7 return new String(bos.toByteArray(),"UTF-8"); 8 }
解码时,
1 XMLDecoder d = new XMLDecoder( 2 new ByteArrayInputStream(ss.getBytes("UTF-8"))); 3 obj = d.readObject(); 4 d.close();
标签:
原文地址:http://www.cnblogs.com/feng0153/p/5665430.html