To deserialize the ReportClientDocument object

This sample uses a String representation of a serialized ReportClientDocument object. You can obtain this value by using the writeExternal method of the ReportClientDocument class and converting the result to a String object.
You can use the readExternal method of the ReportClientDocument class to recreate a ReportClientDocument object from its serialized representation.
  1. Convert the String object to a byte array.
    byte[] bytes = serializedRCD.getBytes();
  2. Create a ByteArrayInputStream that contains the byte array, and then create an ObjectInputStream object that contains the ByteArrayInputStream object.
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
    ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
  3. Create a new ReportClientDocument object, and then call the readExternal method to recreate the ReportClientDocument object from its serialized representation.
    ReportClientDocument rcd = new ReportClientDocument();     
    rcd.readExternal(objectInputStream);
  4. Close the input streams.
    objectInputStream.close();
    byteArrayInputStream.close();
Example: 
This sample creates a ReportClientDocument object from a String representation of its serialized form.
public ReportClientDocument deserializeReport(String serializedRCD) throws IOException, UnsupportedEncodingException, ClassNotFoundException 
{
  byte[] bytes = serializedRCD.getBytes();
        
  ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
  ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
        
  ReportClientDocument rcd = new ReportClientDocument();     
  rcd.readExternal(objectInputStream);

  objectInputStream.close();
  byteArrayInputStream.close();
        
  return rcd;
}
This list includes the classes used by the sample code:
  • com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
  • java.io.ByteArrayInputStream
  • java.io.IOException
  • java.io.ObjectInputStream
  • java.io.UnsupportedEncodingException
  • java.lang.ClassNotFoundException
  • java.lang.String