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 12:32 pm UTC on 30 October 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 fileStream object actually is a MultiByteFileStream object.

See also

FileDirectory example: write a file

FileMan (a thin wrapper).