XML序列化对象时出现中文乱码

public static String ToXmlText(Object obj)throws Exception
    { 
    ByteArrayOutputStream bos= new ByteArrayOutputStream();
    XMLEncoder encoder = new XMLEncoder(bos); 
    encoder.writeObject(obj);
    encoder.flush(); 
    encoder.close();
    return new String(bos.toByteArray(),"UTF-8");
    }  

解码时

XMLDecoder d = new XMLDecoder(
        new ByteArrayInputStream(ss.getBytes("UTF-8")));
obj = d.readObject();
d.close();
http://topic.csdn.net/u/20091112/16/7e64c481-e006-43a0-beec-e7148daf5014.html


你可能感兴趣的:(XML序列化对象时出现中文乱码)