Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2013 00:03
XStream - One of the best Java and XML Framework around - http://codeoftheday.blogspot.com/2013/07/xstream-one-of-best-java-and-xml.html
/**
* XStream - One of the best Java and XML Framework around
* http://codeoftheday.blogspot.com/2013/07/xstream-one-of-best-java-and-xml.html
*/
package smhumayun.codeoftheday.XStreamExample;
import com.thoughtworks.xstream.XStream;
import java.util.Date;
/**
* Main Example class
*
* User: smhumayun
* Date: 7/12/13
* Time: 7:53 PM
*/
public class MainXStreamExample {
public static void main(String[] args) {
//Instantiate XStream
XStream xstream = new XStream();
//Instantiate and initialize any domain object of yours
User user = new User(1, "Syed Muhammad Humayun", new Date(System.currentTimeMillis()));
//Convert your domain object to XML instantly with a single statement call!
System.out.println(xstream.toXML(user));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment