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 ( ..a path encoding quot: ( ..a seq -- ..b seq' ) -- ..b )

file-lines ( path encoding -- seq )

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

change-file-lines ( ..a path encoding quot: ( ..a seq -- ..b seq' ) -- ..b )


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

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

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