The below code is a segment of a Java agent.I exported a Notes document that had imported images in a rich text field to an XML document
I am trying to convert the XML document back to an image
in a folder. It all works except, the image that gets created is blank. Can any one tell me what I am doing wrong or missing…
import lotus.domino.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import org.castor.util.*;
import sun.misc.*;
//Export Imported Images
String exportFileName = "C:\\Temp\\document.xml";
BufferedWriter bw = new BufferedWriter(new FileWriter(exportFileName));
lnDoc.generateXML(bw);
bw.close();
//Convert XML to Image
strInPutXMLData = "C:\\temp\\document.xml";
String data = loadData(strInPutXMLData);
strOutPutImage = "C:\\temp\\" + strGetLeadNumber + "-" + strForm + "out.tif";
this.CreateImage(data, strOutPutImage);
//XML to Image methodes
public boolean CreateImage(String data, String strOutPutFile)
{
byte[] buf = null;
try
{
buf = Base64Decoder.decode(data);
FileOutputStream fo = new FileOutputStream(new File(strOutPutFile));
fo.write(buf);
fo.close();
return true;
}
catch(IOException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
return false;
}
}
public String loadData(String strInputFile)
{
try
{
String s = "";
int str;
FileInputStream fI = new FileInputStream(new File(strInputFile));
str = fI.read();
if (str == -1) return s;
while(str != -1)
{
s = s+ ((char)str);
str = fI.read();
}
fI.close();
return s;
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
return "";
}
}