Reading and writing files
Factor handbook > Input and output

Prev:Streams
Next:Pathnames


Examples of reading and writing files

File streams:
<file-reader> ( path encoding -- stream )

<file-writer> ( path encoding -- stream )

<file-appender> ( path encoding -- stream )


Reading and writing the entire contents of a file; this is only recommended for smaller files:
file-contents ( path encoding -- seq )

set-file-contents ( seq path encoding -- )

change-file-contents ( path encoding quot -- )

file-lines ( path encoding -- seq )

set-file-lines ( seq path encoding -- )

change-file-lines ( path encoding quot -- )


Utility combinators:
with-file-reader ( path encoding quot -- )

with-file-writer ( path encoding quot -- )

with-file-appender ( path encoding quot -- )