JAVA/CORBA CLASSES


Examples: Bytes property
This example gets the total bytes of all the normal files in a directory by opening each file as a stream and getting the Byte property.

import lotus.domino.*;
import java.io.File;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

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

     // (Your code goes here)
     Stream stream = session.createStream();
     int bytes = 0;
     File directory = new File("C:\\StreamFiles");
     String[] files = directory.list();
     for (int i = 0; i < files.length; i++) {
       if (stream.open(directory + "\\" + files[i])) {
         bytes = bytes + stream.getBytes();
         stream.close();
       }
       else
         throw new NotesException
           (NotesError.NOTES_ERR_FILEOPEN_FAILED, "Open failed");
     }
     System.out.println("Number of files = " + files.length);
     System.out.println("Total bytes = " + bytes);
     
   } catch(NotesException e) {
     e.printStackTrace();

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

See Also