Examples: Charset property (Stream - Java™)
This agent uses the file "characters.TRK" with Turkish (ISO-8859-4) characters in it to create a message. To correctly display the message, your machine must be configured to display Unicode in Notes®.
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\\characters.trk";
String charset = "ISO-8859-4";
session.setConvertMIME(false);
Stream inStream = session.createStream();
if (inStream.open(inPath, charset)) {
if (inStream.getBytes() > 0) {
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.replaceItemValue("Form", "Main Topic");
doc.replaceItemValue("Subject", inPath);
MIMEEntity mime = doc.createMIMEEntity();
if (mime != null) {
mime.setContentFromText(inStream,
"text/plain; charset=" + charset, MIMEEntity.ENC_NONE);
mime.encodeContent(MIMEEntity.ENC_QUOTED_PRINTABLE);
System.out.println("Charset = " + mime.getCharset());
}
inStream.close();
doc.save(true, true);
}
else
System.out.println("Input file has no content");
}
else
System.out.println("Input file open failed");
session.setConvertMIME(true);
} catch(NotesException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}