次のエージェントは、ストリームを作成し、選択されている文書の Body アイテムのテキスト値を書き込み、ストリーム内の位置を変更し、ストリームを読み込みます。
import lotus.domino.*;
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();
// Create stream and display properties
Stream stream = session.createStream();
System.out.println("After creating stream:");
System.out.println("¥tBytes = " + stream.getBytes());
System.out.println("¥tCharset = " + stream.getCharset());
System.out.println("¥tIsEOS = " + stream.isEOS());
System.out.println("¥tPosition = " + stream.getPosition());
// Write Body item to stream and display properties
stream.writeText(doc.getItemValueString("Body"));
System.out.println("After writing to stream:");
System.out.println("¥tBytes = " + stream.getBytes());
System.out.println("¥tCharset = " + stream.getCharset());
System.out.println("¥tIsEOS = " + stream.isEOS());
System.out.println("¥tPosition = " + stream.getPosition());
// Reset position to beginning and display properties
stream.setPosition(0);
System.out.println("After setting position of stream to 0:");
System.out.println("¥tBytes = " + stream.getBytes());
System.out.println("¥tCharset = " + stream.getCharset());
System.out.println("¥tIsEOS = " + stream.isEOS());
System.out.println("¥tPosition = " + stream.getPosition());
// Read stream and display
System.out.println(stream.readText());
} catch(NotesException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}