import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
String inPath = "c:¥¥StreamFiles¥¥readme.txt";
// Get the input file
Stream inStream = session.createStream();
if (inStream.open(inPath, "ASCII")) {
if (inStream.getBytes() > 0) {
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.replaceItemValue("Form", "Main Topic");
doc.replaceItemValue("Subject", inPath);
doc.replaceItemValue("Body", inStream.readText());
inStream.close();
doc.save(true, true);
}
else
System.out.println("Input file has no content");
}
else
System.out.println("Input file open failed");
} catch(NotesException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
String inPath = "c:¥¥StreamFiles¥¥readme.txt";
// Get the input file
Stream inStream = session.createStream();
if (inStream.open(inPath, "ASCII")) {
if (inStream.getBytes() > 0) {
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.replaceItemValue("Form", "Main Topic");
doc.replaceItemValue("Subject", inPath);
RichTextItem body = doc.createRichTextItem("Body");
do {
body.appendText(inStream.readText(
Stream.STMREAD_LINE,
Stream.EOL_CRLF));
} while (!inStream.isEOS());
inStream.close();
doc.save(true, true);
}
else
System.out.println("Input file has no content");
}
else
System.out.println("Input file open failed");
} catch(NotesException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}