Bytes (NotesStream - JavaScript)

Read-only. The size of the stream in bytes.

Defined in

NotesStream

Syntax

getBytes() : int

Usage

This property is 0 for a new stream.
The open method sets this property to:
  • 0 for a new file
  • the number of bytes in the file for an existing file
The write method and writeText method increment this property by the number of bytes written to the stream.

The size excludes any detected Unicode signatures or byte order marks.

Examples

This button opens, collects information, and closes the files in a directory.
var filepath:string = requestScope.filepath;
var stream:NotesStream = session.createStream();
var bytes:int = 0;
var files = (new java.io.File(filepath)).listFiles();
for (var i = 0; i < files.length; i++) {
	requestScope.status += "\n" + files[i];
	if (files[i].isFile()) {
		try {
			if (stream.open(files[i].getPath())) {
				bytes += stream.getBytes();
				requestScope.status += ", " + stream.getBytes() + " bytes";
				stream.close();
			} else {
				requestScope.status += ", cannot open";
			}
		} catch(e) {
			requestScope.status += ", cannot open";
		}
	}
}
requestScope.status += "\n" + "Number of files = " + files.length;
requestScope.status += "\n" + "Total bytes = " + bytes;