Hi,
I am getting a runtime error using the new 3.0 java library
this is the sample code i am using:
public void convertToBase64File(String fileName, ConversionConfig config, int nLoop) {
InputStream inputStream = null;
Base64InputStream b64is = null;
try {
calculateMemoryStats(“2”);
ConversionHandler conversionHandler = new ConversionHandler(config);
ImageSaveOptions imageSaveOptions = new ImageSaveOptions();
imageSaveOptions.setConvertFileType(ImageSaveOptions.ImageFileType.Png);
for (int j = 1; j < 6; j++) {
// imageFileName is the finally generated file name
//String imageFileName = conversionHandler.convertToImage(
// fileName, imageSaveOptions);
imageSaveOptions.setPageNumber(j);
try
{
GroupDocsInputStream gis = conversionHandler.convert(fileName, imageSaveOptions);
b64is = null;
b64is = new Base64InputStream(gis.toInputStream(),true,0,new byte[0]);
FileOutputStream fos = new FileOutputStream(new File(“C://temp//sample_” + nLoop + “_” + j + “.base64”),true);
fos.write((new String("{“source”:“ETMF”,").getBytes()));
fos.write((new String("“cur_pg”:“1”,").getBytes()));
fos.write((new String("“obj_id”:“090001803635252”,").getBytes()));
fos.write((new String("“tot_pg”:“5”,").getBytes()));
fos.write((new String("“rec_id”:“0900018073635”,").getBytes()));
fos.write((new String("“image”:"").getBytes()));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = b64is.read(bytes)) != -1) {
fos.write(bytes, 0, read);
}
fos.write((new String(""}").getBytes()));
fos.flush();
fos.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
if (inputStream != null) try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
if (b64is != null) try {
b64is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
finally
{
if (inputStream != null) try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
if (b64is != null) try {
b64is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
This is the runtime error:
java.lang.ClassCastException: com.aspose.ms.System.a.a.n cannot be cast to com.groupdocs.foundation.utils.wrapper.stream.GroupDocsInputStream
at com.groupdocs.conversion.examples.GroupDocsUtil.convertToBase64File(GroupDocsUtil.java:219)
at com.groupdocs.conversion.examples.TestMain2.main(TestMain2.java:51)
java.lang.ClassCastException: com.aspose.ms.System.a.a.n cannot be cast to com.groupdocs.foundation.utils.wrapper.stream.GroupDocsInputStream
at com.groupdocs.conversion.examples.GroupDocsUtil.convertToBase64File(GroupDocsUtil.java:219)
at com.groupdocs.conversion.examples.TestMain2.main(TestMain2.java:51)
java.lang.ClassCastException: com.aspose.ms.System.a.a.n cannot be cast to com.groupdocs.foundation.utils.wrapper.stream.GroupDocsInputStream
at com.groupdocs.conversion.examples.GroupDocsUtil.convertToBase64File(GroupDocsUtil.java:219)
at com.groupdocs.conversion.examples.TestMain2.main(TestMain2.java:51)
java.lang.ClassCastException: com.aspose.ms.System.a.a.n cannot be cast to com.groupdocs.foundation.utils.wrapper.stream.GroupDocsInputStream
at com.groupdocs.conversion.examples.GroupDocsUtil.convertToBase64File(GroupDocsUtil.java:219)
at com.groupdocs.conversion.examples.TestMain2.main(TestMain2.java:51)
java.lang.ClassCastException: com.aspose.ms.System.a.a.n cannot be cast to com.groupdocs.foundation.utils.wrapper.stream.GroupDocsInputStream
at com.groupdocs.conversion.examples.GroupDocsUtil.convertToBase64File(GroupDocsUtil.java:219)
Please let us know how to resolve this.
Thanks