readText (NotesStream - JavaScript)

Reads text lines from a stream.

Defined in

NotesStream

Syntax

readText() : string

readText(oneLine:int) : string

readText(oneLine:int, endOfLine:int) : string

Parameter Description
oneLine
  • NotesStream.STMREAD_LINE 0 reads one line.
  • Defaults to the entire stream to a maximum of 2GB.
endOfLine End-of-line character(s) appended to the text. The default is NotesStream.EOL_NONE.
  • NotesStream.EOL_CR 2 appends a carriage return (ASCII 13).
  • NotesStream.EOL_CRLF 0 appends a carriage return and line feed (ASCII 10 + 13).
  • NotesStream.EOL_LF 1 appends a line feed (ASCII 10).
  • NotesStream.EOL_NONE 5 appends nothing.
  • NotesStream.EOL_PLATFORM 3 follows the conventions of the current platform.
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";