JAVA/CORBA クラス


例:truncate メソッド
次のエージェントは、ファイルでストリームを開き、書き込みを行います。すでにファイルに内容がある場合、書き込み前にエージェントによって切り捨てられます。

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

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

     // (Your code goes here)
     
     // Get the input file
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     Document doc = dc.getFirstDocument();
     String outPath =
     "c:\\StreamFiles\\" + doc.getItemValueString("Subject") + ".txt";
     Stream outStream = session.createStream();
     if (outStream.open(outPath, "ASCII")) {
       if (outStream.getBytes() > 0)
         outStream.truncate();
       outStream.writeText(doc.getItemValueString("Body"));
       outStream.close();
     }
     else
       System.out.println("Output file open failed");
     
   } catch(NotesException e) {
     e.printStackTrace();

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

関連項目