xml到Java Bean
/** 时 代 J a v a 公 众 号 提 供 **/ //package com.nowjava; import java.beans.XMLDecoder; import java.io.*; import java.nio.charset.StandardCharsets; public class Main { public static Object xmlToBean(String beanXml) { byte[] bytes = beanXml.getBytes(StandardCharsets.UTF_8); return xmlDecode(bytes); } /*nowjava 提供*/ public static Object xmlDecode(byte[] bytes) { Object obj; InputStream is = new ByteArrayInputStream(bytes); try (XMLDecoder d = new XMLDecoder(is)) { obj = d.readObject(); } return obj; }