extractFile(String path) created empty file

I use a Java application to process e-mails received with attachment. It uses method extractFile(String path) to store the file attachment to a local disk file.

orderDir = localdir + File.separator + cnum + File.separator + OID + File.separator ;

if (debug) Utility.DEBUG(pgname,“orderDir”,orderDir);

if (!Utility.verifyCreatePath(orderDir))

throw new Exception("Failed to create order directory : " + orderDir);				

String fileAttachment = orderDir + OID + “.TXT”;

if (debug) Utility.DEBUG(pgname,“fileAttachment”,fileAttachment);

if (!doc.hasEmbedded())throw new Exception(“The e-mail does not contain file attachment”);

if (debug) Utility.DEBUG(pgname,mname,“start get embeddedObj”);

String attachment = attachmentFileName(ee);

EmbeddedObject eobj = doc.getAttachment(attachment);

if (debug) Utility.DEBUG(pgname,mname,“start write file”);

if (debug) Utility.DEBUG(pgname,“attachment file name”,attachment);

if ((eobj != null) && (eobj.getType() == EmbeddedObject.EMBED_ATTACHMENT)){

try {   	

	eobj.extractFile(fileAttachment);  

} catch (NotesException e) {

	throw new Exception("Failed to save attachment : "+e);

}

} else {

throw new Exception("E-mail does not contain file attachment");

}

if (debug) Utility.DEBUG(pgname,mname,“end write file”);

java.io.BufferedReader fileContent = new java.io.BufferedReader(new java.io.FileReader(fileAttachment));

if (fileContent.ready()) // return False if buffer is empty

readFileAttachment(fileContent,ee) ; 

else

throw new Exception("Attachment "+ fileAttachment+" is empty.");

fileContent.close();

For some particular e-mails received with file attachments, method eobj.extractFile(fileAttachment) just created empty files on local hard disk. When I re-ran with the same e-mails, I got got the same result. However when I did cut-and-paste the problem e-mails to create new e-mails using Lotus Notes and used the newly created e-mails as input, the problem did not happen.

Any clues for what’s went wrong? Thanks.