method writeLengthPrefixedString

void writeLengthPrefixedString(int32 prefixSizeInBytes,string string,string encoding);

Argumente

Zurückgegebener Wert

This method encodes and writes the passed in string and advance the stream's position. The length of the encoded string in bytes will first be wrtten to the stream before the string data. The size in bytes of the prefix is determined by the prefixSizeInBytes parameter. If the encoded length is larger than can be fit in an unsigned integer of size prefixSizeInBytes then an error is returned. If the write fails then the stream's position is unaffected.
var fileStreamObj = shell.serviceManager.basics.fileStream;
var streamWriterObj = shell.serviceManager.basics.rawStreamWriter;

fileStreamObj.openForWrite("c:\\temp\\test2.txt", true, true);
streamWriterObj.stream = fileStreamObj;

//this will write the content currently in text.txt to the end of itself
streamWriterObj.writeLengthPrefixedString("4", "Test writeLengthPrefixedString", "");

fileStreamObj.close();