IsReadOnly (NotesStream - JavaScript™)
Indicates that the stream is associated with a read-only file.
Defined in
NotesStreamSyntax
isReadOnly() : boolean
Legal value | Description |
---|---|
true |
indicates read-only |
false |
indicates writable |
Usage
This property is true if the stream is opened to a read-only file. Otherwise it is false.Write operations on a read-only file throw an exception.
Examples
This button writes thesubject
and body
items
of the current document to a text file. The button first ensures that
the file does not exist as a read-only file.var filepath:string = database.getFileName();
filepath = "c:\\" + filepath.left(filepath.length - 3) + "txt";
requestScope.status = "Output file: " + filepath;
var stream:NotesStream = session.createStream();
if (stream.open(filepath, "ASCII")) {
if (stream.isReadOnly()) {
requestScope.status = filepath + " is read-only";
return;
}
stream.truncate();
requestScope.status += "\nBytes written: " +
stream.writeText(currentDocument.getItemValueString("subject"),
NotesStream.EOL_CRLF);
if (document1.hasItem("body")) {
requestScope.status += "\nBytes written: " +
stream.writeText(document1.getItemValue("body").firstElement());
} else {
requestScope.status += "\nBytes written: 0";
}
stream.close();
} else {
requestScope.status = "Output file open failed";
}