Simple Question

Mark Guzdial guzdial at cc.gatech.edu
Mon Sep 28 18:40:54 UTC 1998


>Could some kind soul give me a little hand up with this very simple task
>that is none the less baffling me:
>
>Could you show me a code snippet that will allow me to:
>
>    Open an existing file for reading
>    Open a new file for writing
>    Read the input file a line at a time
>    Write the line into  the output file
>

| fileIn fileOut aLine |
fileIn := FileStream fileNamed: 'fred.txt'.
fileOut := FileStream fileNamed: 'wilma.txt'.
[fileIn atEnd] whileFalse:
	[aLine := fileIn upTo: (Character cr).
	fileOut nextPutAll: aLine; cr.].

I didn't try it, but I think it's about right.

Mark

--------------------------
Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280
(404) 894-5618 : Fax (404) 894-0673 : guzdial at cc.gatech.edu
http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html





More information about the Squeak-dev mailing list