GNU Smalltalk User's Guide
4.10.3 Files
Streams can also operate on files. If you wanted to
dump the file `/etc/passwd' to your terminal, you could
create a stream on the file, and then stream over its contents:
| | Smalltalk at: #f put: (FileStream
open: '/etc/passwd'
mode: FileStream read) !
f do: [ :c | Transcript nextPut: c ] !
f position: 30 !
25 timesRepeat: [ Transcript nextPut: (f next) ] !
f close !
|
and, of course, you can load Smalltalk source code into your
image:
| | FileStream fileIn: '/users/myself/src/source.st' !
|