How to Serialize Objects with Skaringa

1) Create the SkaringaSample.java file:

import com.skaringa.javaxml.ObjectTransformer;
import com.skaringa.javaxml.ObjectTransformerFactory;

import java.io.File;

import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;

import static java.lang.System.out;

public final class SkaringaSample {

  public static void main(final String[] args) throws Exception {
    final ObjectTransformerFactory factory = ObjectTransformerFactory.getInstance();

    final ObjectTransformer transformer = factory.getImplementation();

    transformer.serialize("Hello World", new StreamResult(new File("Sample.xml")));
  }

}

2) Compile the SkaringaSample.java file.

3) Launch the SkaringaSample class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s