c盘清理的步骤是什么(如何清理C盘空间)
如何清理C盘空间怎么清理C盘的垃圾文件?每天上网会给电脑带来很多临时文件,这些垃圾文件不清理掉时间久了就会影响到电脑的运行速度。那怎
2022/12/08
【资料图】
@XmlRootElement(name = "Root")public class Student { private String id; private String name; private String age; private StdClass stdClass; @XmlElement(name = "ID") public String getId() { return id; } public void setId(String id) { this.id = id; } @XmlElement(name = "Name") public String getName() { return name; } public void setName(String name) { this.name = name; } @XmlElement(name = "Age") public String getAge() { return age; } public void setAge(String age) { this.age = age; } @XmlElement(name = "StdClass") public StdClass getStdClass() { return stdClass; } public void setStdClass(StdClass stdClass) { this.stdClass = stdClass; }}
public class StdClass { private String name; private ListteacherList; @XmlAttribute public String getName() { return name; } public void setName(String name) { this.name = name; } @XmlElementWrapper(name = "TeacherList") @XmlElement(name = "Teacher") public List getTeacherList() { return teacherList; } public void setTeacherList(List teacherList) { this.teacherList = teacherList; }}
public class Teacher { private String name; @XmlAttribute public String getName() { return name; } public void setName(String name) { this.name = name; }}
public class TestService { public static void main(String[] args) { Student student = new Student(); student.setId(UUID.randomUUID().toString()); student.setAge("20"); student.setName("wzd"); StdClass stdClass = new StdClass(); stdClass.setName("一班"); student.setStdClass(stdClass); ArrayListteachers = new ArrayList<>(); Teacher teacher = new Teacher(); teacher.setName("yxl"); teachers.add(teacher); teachers.add(teacher); stdClass.setTeacherList(teachers); System.out.println(objToXmlStr(student)); } /** * xmlobj 转成 xml String * @param object * @return */ public static String objToXmlStr(Object object) { String resStr = ""; try { JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); StringWriter stringWriter = new StringWriter(); marshaller.marshal(object, stringWriter); resStr = stringWriter.toString(); stringWriter.close(); } catch (Exception e) { e.printStackTrace(); } return resStr; } /** * xml string 转 object * @param clazz * @param xmlStr * @return */ public static Object XmlStrToObj(Class> clazz, String xmlStr) { Object xmlObj = null; Reader reader = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(clazz); Unmarshaller unMarshaller = jaxbContext.createUnmarshaller(); reader = new StringReader(xmlStr); xmlObj = unMarshaller.unmarshal(reader); reader.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return xmlObj; }}
20 0d6961c4-f88c-4598-abb4-92a8fbbfdb0b wzd yxl yxl
/** * 反射校验xml标签、属性 * @param bean * @param str */ public static void checkObjField(Object bean, String str) { try { Class> clazz = bean.getClass(); Field[] declaredFields = clazz.getDeclaredFields(); for (Field field : declaredFields) { field.setAccessible(true); String name = field.getName(); Object o = field.get(bean); Method method = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)); XmlElement xmlElement = method.getAnnotation(XmlElement.class); if (xmlElement != null) { if (!str.contains("<" + xmlElement.name()) && !"errorCode".equals(xmlElement.name())) { System.out.println(xmlElement.name() + "标签错误"); } } XmlAttribute xmlAttribute = method.getAnnotation(XmlAttribute.class); if (xmlAttribute != null) { if (!str.contains(xmlAttribute.name() + "=")) { System.out.println(xmlAttribute.name() + "属性错误"); } } if (o instanceof List) { List
标签: