Examples: Name property (DbDirectory - Java)

This agent prints the file name and title of every template (.nsf file) on the server specified in the agent comment.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Agent agent = agentContext.getCurrentAgent();
      DbDirectory dir = session.getDbDirectory
      (agent.getComment());
      String server = dir.getName();
      if (server.equals("")) server = "Local";
      System.out.println("Templates on " + server + "\n");
      Database db = dir.getFirstDatabase
      (DbDirectory.TEMPLATE);
      while (db != null) {
        System.out.println(db.getTemplateName());
        db.open();
        System.out.println("Last modified: " +
        db.getLastModified().getLocalTime());
        db = dir.getNextDatabase(); }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}