To serialize the ReportClientDocument object

You can use the writeExternal method of the ReportClientDocument class to create a serialized representation of a ReportClientDocument object.
  1. Create a new ByteArrayOutputStream object.
    ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
  2. Create a new ObjectOutputStream object that contains the ByteArrayOutputStream object.
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutput);
  3. Write the contents of the ReportClientDocument object to the ObjectOutputStream object by calling the writeExternal method.
    rcd.writeExternal(objectOutputStream);
  4. Close the output streams.
    objectOutputStream.close();
    byteArrayOutput.close();
  5. Call the toString method to convert the output stream to a String object.
    String reportSerialized = byteArrayOutput.toString();
Note: To use the String object in a URL, convert it to a URL-encoded string using a class such as java.net.URLEncoder.
Example: 
This sample serializes a ReportClientDocument object and returns a String object that represents its serialized form.
public String serializeReport(ReportClientDocument rcd) throws IOException, UnsupportedEncodingException
{   
  ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
  ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutput);
    	
  rcd.writeExternal(objectOutputStream);
    	
  objectOutputStream.close();
  byteArrayOutput.close();
  
 	String reportSerialized = byteArrayOutput.toString();
  
  return reportSerialized;
}
This list includes the classes used by the sample code:
  • com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
  • java.io.ByteArrayOutputStream
  • java.io.IOException
  • java.io.ObjectOutputStream
  • java.io.UnsupportedEncodingException
  • java.lang.ClassNotFoundException
  • java.lang.String