次のエージェントは、java.io.OutputStreamWriter を使用してストリームに書き込みを行います。
import lotus.domino.*;
import java.io.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
String outPath =
"c:¥¥StreamFiles¥¥" + doc.getItemValueString("Subject") + ".txt";
FileOutputStream fos = new FileOutputStream(outPath);
OutputStreamWriter osw = new OutputStreamWriter(fos);
Stream outStream = session.createStream();
outStream.writeText(doc.getItemValueString("Body"));
outStream.getContents(osw);
osw.close();
} catch(NotesException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}