txt: ## spurt.md
  spurt
  
  Combined from primary sources listed below.
  
  # [In IO::Handle](#___top "go to top of document")[§](#(IO::Handle)_method_spurt "direct link")
  
  See primary documentation
  [in context](/type/IO/Handle#method_spurt)
  for **method spurt**.
  
  ```raku
  multi method spurt(IO::Handle:D: Blob $data, :$close = False)
  multi method spurt(IO::Handle:D: Cool $data, :$close = False)
  ```
  
  Writes all of the `$data` into the filehandle, closing it when finished, if `$close` is `True`. For [`Cool`](/type/Cool) `$data`, will use the encoding the handle is set to use ([`IO::Handle.open`](/routine/open) or [`IO::Handle.encoding`](/routine/encoding)).
  
  Behavior for spurting a [`Cool`](/type/Cool) when the handle is in binary mode or spurting a [`Blob`](/type/Blob) when the handle is NOT in binary mode is undefined.
  
  # [In IO::Path](#___top "go to top of document")[§](#(IO::Path)_method_spurt "direct link")
  
  See primary documentation
  [in context](/type/IO/Path#method_spurt)
  for **method spurt**.
  
  ```raku
  method spurt(IO::Path:D: $data, :$enc, :$append, :$createonly)
  ```
  
  Opens the path for writing, and writes all of the `$data` into it. File will be closed afterwards. Will [`fail`](/routine/fail) if it cannot succeed for any reason. The `$data` can be any [`Cool`](/type/Cool) type or any [`Blob`](/type/Blob) type. Arguments are as follows:
  
  * `:$enc` — character encoding of the data. Takes same values as `:$enc` in [`IO::Handle.open`](/routine/open). Defaults to `utf8`. Ignored if `$data` is a [`Blob`](/type/Blob).
  * `:$append` — open the file in `append` mode, preserving existing contents, and appending data to the end of the file.
  * `:$createonly` — [`fail`](/routine/fail) if the file already exists.
  
  ```raku
  method spurt(IO::Path:D:)
  ```
  
  As of the 2020.12 release of the Rakudo compiler, it is also possible to call the `spurt` method without any data. This will either create an empty file, or will truncate any existing file at the given path.
  
  # [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_spurt "direct link")
  
  See primary documentation
  [in context](/type/independent-routines#sub_spurt)
  for **sub spurt**.
  
  ```raku
  multi spurt(IO() $path, |c)
  ```
  
  The `$path` can be any object with an IO method that returns an [`IO::Path`](/type/IO/Path) object. Calls [`IO::Path.spurt`](/routine/spurt) on the `$path`, forwarding any of the remaining arguments.
  