使用EmbeddedObject从Lotus Notes API中提取附件,在系统文件夹中创建eo * tm文件 [英] Extracting attachments from lotus notes api using EmbeddedObject, Creating eo*tm file in system folder

查看:166
本文介绍了使用EmbeddedObject从Lotus Notes API中提取附件,在系统文件夹中创建eo * tm文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用EmbeddedObjects提取附件,我能够提取附件,但可以在系统temp文件夹中创建em * tm临时文件.

I am trying to extract attachments using EmbeddedObjects, I am able to extract attachments but create em*tm temp files in system temp folder.

 EmbeddedObject embeddedObject=document.getAttachment(attachmentName);
 InputStream inputStream=embeddedObject.getInputStream();
 .....
 ......
 inputStream.close();
 embeddedObject..recycle();
 document..recycle();

关闭输入流后,它不会从系统临时文件夹中删除临时文件. 我的代码或其Lotus Notes的设置问题有什么问题吗?

After closing input Stream its not deleting temp file form system temp folder. Is it any thing wrong in my code or its setting issue with lotus notes.

您能帮我吗?

感谢您的帮助.

推荐答案

这是一个常见问题,它与对象的错误关闭/回收(丢失或乱序)有关.将在对象处于活动状态时创建E0 * TM文件,并在回收时对其进行清理.

This is a common issue, and it relates to the incorrect closure/recycle of objects (either missing or out of sequence). E0*TM files will be created while the objects are alive and cleaned up when recycled.

如果它们正确,请检查是否正在运行的防病毒软件阻止删除.

If they are correct then check to see if any Antivirus software running that is blocking deletion.

下面的示例代码我曾在工作之前对其进行过测试,因此请与您的代码进行比较.

The following sample code I used to test this before works, so compare to yours.

  try { 

   System.out.println("Start"); 
   String path = "test.txt";    

   Session session = getSession();  
   AgentContext agentContext = session.getAgentContext();   

   System.out.println("Get DB");    
   Database db = session.getCurrentDatabase();  

   System.out.println("View + doc");    
   View vw = db.getView("main");    
   Document doc = vw.getFirstDocument();    

   System.out.println("Embedded object");   
   EmbeddedObject att = doc.getAttachment(path);    
   InputStream is = att.getInputStream();   
   ByteArrayOutputStream fos = new ByteArrayOutputStream(); 

   byte buffer[] = new byte[(int) att.getFileSize()];   
   int read;    
   do { 
    read = is.read(buffer, 0, buffer.length);   
    if (read > 0) { 
     fos.write(buffer, 0, read);    
    }   
   } while (read > -1); 

   fos.close(); 
   is.close();

   // recycle the domino variables  
   doc.recycle();   
   vw.recycle();    
   db.recycle();    
   att.recycle();   

  } catch (Exception e) {   
   e.printStackTrace(); 
  }

这篇关于使用EmbeddedObject从Lotus Notes API中提取附件,在系统文件夹中创建eo * tm文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆