Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to write a file
Last updated at 4:37 pm UTC on 12 March 2019
 fileStream := FileStream newFileNamed: 'theFileName.txt'.
 fileStream nextPutAll:  'Some text';cr.
 fileStream nextPutAll:  'Some more text';cr.
 fileStream close.



 | fname fileStream  |
 "relative path for all-in-one package"
 fname :=  '../../../export/theFileName2.txt'.
 (FileDirectory forFileName: fname) assureExistence.
  fileStream := FileStream newFileNamed: fname. 
  fileStream nextPutAll:  'Some text';cr.
  fileStream nextPutAll:  'Some more text';cr.
  fileStream close.


Note

The method #forFileName: actually returns a MultiByteFileStream object.

See also

FileDirectory example: write a file

FileMan (a thin wrapper).