close (NotesStream - JavaScript)

Releases the file, if any, associated with the stream.

Defined in

NotesStream

Syntax

close() : void

Usage

It is recommended that you close streams explicitly using this method, although they close implicitly at the end of their scope.

Closing a stream with zero bytes deletes the associated file.

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;