readText (NotesStream - JavaScript™)
Reads text lines from a stream.
Defined in
NotesStreamSyntax
readText() : string
Parameter | Description |
---|---|
oneLine |
|
endOfLine |
End-of-line character(s) appended to the text.
The default is NotesStream.EOL_NONE .
|
Return value | Description |
---|---|
string |
The text read. |
Usage
This method starts at getPosition and reads text until end of line, including the end-of-line character, or end of stream.Examples
This button creates a document whose body contains the content of a file.var inPath:string = requestScope.filepath;
var inStream:NotesStream = session.createStream();
if (inStream.open(inPath, "ASCII")) {
if (inStream.getBytes() > 0) {
var doc = database.createDocument();
doc.replaceItemValue("Form", "main");
doc.replaceItemValue("subject", inPath);
doc.replaceItemValue("body", inStream.readText());
doc.save(true, true);
} else requestScope.status = "Input file has no content";
inStream.close();
} else requestScope.status = "Input file open failed";
This
button is the same except that it processes the file a line at a time.
var inPath:string = requestScope.filepath;
var inStream:NotesStream = session.createStream();
if (inStream.open(inPath, "ASCII")) {
if (inStream.getBytes() > 0) {
var doc = database.createDocument();
doc.replaceItemValue("Form", "main");
doc.replaceItemValue("subject", inPath);
var body:NotesRichTextItem = doc.createRichTextItem("body");
do {
body.appendText(inStream.readText(NotesStream.STMREAD_LINE,
NotesStream.EOL_CRLF));
} while (!inStream.isEOS());
doc.save(true, true);
} else requestScope.status = "Input file has no content";
inStream.close();
} else requestScope.status = "Input file open failed";