Player APIs (BrightScript & Ja...
...
Object Reference
File Objects
roReadWriteFile
12min
the object opens a file and allows both reading and writing operations on that file object creation creating an roreadwritefile object opens an existing file for both reading and writing object creation fails if the file does not exist the current position is set to the beginning of the file createobject("roreadwritefile", filename as string) ifreadstream setreceiveeol(eol sequence as string) as void sets the eol sequence when reading from the stream readbyte() as integer reads a single byte from the stream, blocking if necessary if the eof is reached or there is an error condition, then a value less than 0 is returned readbyteifavailable() as integer reads a single byte from the stream if one is available if no bytes are available, it returns immediately a return value less than 0 indicates either that the eof has been reached or no byte is available readline() as string reads until it finds a complete end of the line sequence if it fails to find the sequence within 4096 bytes, then it returns the 4096 bytes that are found no data is discarded in this case readblock(size as integer) as string reads the specified number of bytes the number is limited to 65536 bytes in the event of an eof or an error, fewer bytes than requested will be returned any null bytes in the file will mask any further bytes ateof() as boolean returns true if an attempt has been made to read beyond the end of the file if the current position is at the end of the file, but no attempt has been made to read beyond it, this method will return false ifstreamsend setsendeol(eol sequence as string) as void sets the eol sequence when writing to the stream the default value is cr+lf if you need to set this value to a non printing character, use the chr() global functions docid\ nsjxffr7olfgdwgjfebme sendbyte(byte as integer) as void writes the specified byte to the stream sendline(string as string) as void writes the specified characters to the stream followed by the current eol sequence sendblock(a as dynamic) as void writes the specified characters to the stream this method can support either a string or an robytearray if the block is a string, any null bytes will terminate the block flush() as void writes the stream to the file, blocking execution until all data is written out asyncflush() as void writes the stream to the file within a few seconds the system will not block execution while writing to the file the system performs an asynchronous flush automatically when the object instance is destroyed (for instance, when the the variable containing it is reassigned) the stream is first written to the kernel, which then writes it to the file system when resources are available ifstreamseek seekabsolute(offset as integer) as void seeks the specified offset if the offset is beyond the end of the file, then the file will be extended upon the next write and any previously unoccupied space will be filled with null bytes seekrelative(offset as integer) as void seeks to the specified offset relative to the current position if the ultimate offset is beyond the end of the file, then the file will be extended as described in seekabsolute() seektoend() as void seeks to the end of the file currentposition() as integer retrieves the current position within the file