You can use the
writeExternal
method of the
ReportClientDocument class to
create a serialized representation of a
ReportClientDocument object.
Create a new
ByteArrayOutputStream object.
ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
Create a new
ObjectOutputStream object that
contains the
ByteArrayOutputStream object.
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutput);
Write the contents of the
ReportClientDocument object to
the
ObjectOutputStream
object by calling the
writeExternal method.
rcd.writeExternal(objectOutputStream);
Close the output streams.
objectOutputStream.close();
byteArrayOutput.close();
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