JAVA/CORBA CLASSES

Examples: Stream class
This agent creates a stream, writes to it the text value of the Body item of the selected document, changes position in the stream, and reads the stream.

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();
   }
 }
}

See Also