@Test public void xmlToObject()throws Exception { XStreamSample.objectToXml(); User u = XStreamSample.xmlToObject(); assertNotNull(u); assertEquals("xstream", u.getUserName()); for (LoginLog log : u.getLogs()) { assertNotNull(log); assertNotNull(log.getIp()); assertNotNull(log.getLoginDate()); } }
public static User xmlToObject() throws Exception { FileInputStream fis = new FileInputStream("out/XStreamSample.xml"); User u = (User) xstream.fromXML(fis); for (LoginLog log : u.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return u; }
XStreamSample { public static User xmlToObject() throws Exception { FileInputStream fis = new FileInputStream("out/XStreamSample.xml"); User u = (User) xstream.fromXML(fis); for (LoginLog log : u.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return u; } }
XStreamSample { public static User xmlToObject() throws Exception { FileInputStream fis = new FileInputStream("out/XStreamSample.xml"); User u = (User) xstream.fromXML(fis); for (LoginLog log : u.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return u; }  }
XStreamSample { public static User xmlToObject() throws Exception { FileInputStream fis = new FileInputStream("out/XStreamSample.xml"); User u = (User) xstream.fromXML(fis); for (LoginLog log : u.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return u; }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args); }
XStreamSample { public static User xmlToObject() throws Exception { FileInputStream fis = new FileInputStream("out/XStreamSample.xml"); User u = (User) xstream.fromXML(fis); for (LoginLog log : u.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return u; }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args);  }