Write - Maple Help

FileTools[Compressed]

 Write
 write data to a compressed file

 Calling Sequence Write(file, data)

Parameters

 file - string or integer file descriptor data - string or rtable of hardware datatype numbers

Description

 • The Write command compresses and writes data to a file that has been opened with FileTools[Compressed][Open].

Examples

 > $\mathrm{file}≔\mathrm{FileTools}\left[\mathrm{TemporaryFilename}\right]\left(\mathrm{FileTools}\left[\mathrm{JoinPath}\right]\left(\left[\mathrm{FileTools}\left[\mathrm{TemporaryDirectory}\right]\left(\right),"GZtest-"\right]\right)\right)$
 ${\mathrm{file}}{≔}{"/tmp/mpldoc5/GZtest-yYoYxV9R"}$ (1)
 > $\mathrm{fd}≔\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Open}\right]\left(\mathrm{file}\right)$
 ${\mathrm{fd}}{≔}{32518976}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Write}\right]\left(\mathrm{fd},"String1"\right)$
 ${7}$ (3)
 > $\mathrm{data}≔\mathrm{StringTools}\left[\mathrm{ToByteArray}\right]\left("String2"\right)$
 ${\mathrm{data}}{≔}\left[\begin{array}{ccccccc}{83}& {116}& {114}& {105}& {110}& {103}& {50}\end{array}\right]$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Write}\right]\left(\mathrm{file},\mathrm{data}\right)$
 ${7}$ (5)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Close}\right]\left(\mathrm{fd}\right)$
 ${0}$ (6)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{ReadFile}\right]\left(\mathrm{file},\mathrm{string}\right)$
 ${"String1String2"}$ (7)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left(\mathrm{file}\right)$
 > $\mathrm{zipfile}≔\mathrm{FileTools}\left[\mathrm{TemporaryFilename}\right]\left(\mathrm{cat}\left(\mathrm{FileTools}\left[\mathrm{TemporaryDirectory}\right]\left(\right),\mathrm{kernelopts}\left(\mathrm{dirsep}\right),"GZtest-"\right),".zip"\right)$
 ${\mathrm{zipfile}}{≔}{"/tmp/mpldoc5/GZtest-bx70dpPu.zip"}$ (8)
 > fd := FileTools[Compressed][Open]("dataOne" in zipfile,'mode'=WRITE);
 ${\mathrm{fd}}{≔}{0}$ (9)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Write}\right]\left(\mathrm{fd},"String1"\right)$
 ${7}$ (10)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Write}\right]\left(\mathrm{fd},"String2"\right)$
 ${8}$ (11)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Close}\right]\left(\mathrm{fd}\right)$
 ${0}$ (12)
 ${"String1 String2"}$ (13)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left(\mathrm{zipfile}\right)$

Compatibility

 • The FileTools[Compressed][Write] command was introduced in Maple 16.