www.delorie.com/gnu/docs/smalltalk/gst_89.html   search  
 
Buy GNU books!


GNU Smalltalk User's Guide

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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' !


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003