The [file->writeBytes] method takes in a [bytes] object and writes those bytes to the file referenced in the [file] object's path.
There are two optional parameters that can be passed to the method, the first is the position in the [bytes] object to start writing from and the second is the number of bytes to write. The default values for these parameters are to start at the beginning of the byte stream (1) and write all the bytes ([bytes->size]).
local(f) = file(...)
#f->writeBytes
The code below will create a copy of the file "logo.png" with the name "logo2.png" and make sure both files are properly closed.
Code
local(my_file) = file('/rhino/logo.png')
local(new_file) = file('/rhino/logo2.png')
#my_file->doWithClose => {
handle => { #new_file->close }
#new_file->writeBytes(#my_file->readBytes)
}
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments