views:

42

answers:

1

I would like to convert a Java Object to a String containing the marshaled XML data. One of the ways I could find was to first marshal to a File and then read the file using BufferedReader to convert into a String. I feel this may not be the most efficient way, because the IO operations are performed twice (Once during marshaling and the second time during the conversion of file content into String)

Could anyone please suggest any better approach?

+5  A: 

Pass a StringWriter object as argument to marshal method of Marshaller

saugata
Thank you for the suggestion..
Mithun