Lasso Soft Inc. > Home

[ file->writeBytes ]

Method

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]).

  • Syntax
local(f) = file(...)
#f->writeBytes
Examples
  • Beginner

Duplicate a file

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)
}

Recent Comments

No Comments found

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. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft