1.unmarshal from file
"input.xml" -> Object
// unmarshal customer information from file
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
FileInputStream in = new FileInputStream("input.xml");
Order order = (Order)uctx.unmarshalDocument(in, null);
2.marshal object to file
Object -> "out.xml"
// marshal object back out to file (with nice indentation, as UTF-8)
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
FileOutputStream out = new FileOutputStream("out.xml");
mctx.setOutput(out, null);
mctx.marshalDocument(order);