write (NotesStream - JavaScript™)
Writes bytes to a stream.
Defined in
NotesStreamSyntax
write(buffer:byte[]) : int
Parameter | Description |
---|---|
buffer |
The bytes to write, to a maximum of 2GB. |
Return value | Description |
---|---|
int |
The number of bytes written. |
Usage
This method appends the bytes to the end of the stream.This method throws an exception if the stream is read-only. See IsReadOnly.
When a stream is written, property values are:
Examples
This button makes an exact copy of a file.var inPath:string = requestScope.filepath;
var n:int = inPath.lastIndexOf(".");
var outPath:string = inPath.left(n) + "Copy" + inPath.right(inPath.length - n);
var inStream:NotesStream = session.createStream();
if (inStream.open(inPath, "binary")) {
if (inStream.getBytes() > 0) {
var outStream:NotesStream = session.createStream();
if (outStream.open(outPath, "binary")) {
if (!outStream.isReadOnly()) {
do {
var buffer = inStream.read(32767);
outStream.write(buffer);
} while (!inStream.isEOS());
} else requestScope.status = "Output file exists and is read-only";
outStream.close();
} else requestScope.status = "Output file open failed";
} else requestScope.status = "Input file has no content";
inStream.close();
} else requestScope.status = "Input file open failed";