[newbie] My problem.
Jon Hylands
Jon at huv.com
Sat Aug 19 12:40:55 UTC 2000
On Sat, 19 Aug 2000 05:32:11 +0100, "C kennedy" <colmk at eircom.net> wrote:
> I need to read in a text file to the Squeak environment.
> How do I do this?
You create an instance of a FileStream on the file.
file := FileStream fileNamed: 'test.txt'.
Then you can do things like...
Process a line at a time:
[file atEnd] whileFalse: [
line := file nextLine.
"Process the line"
]
Or just read the whole file into a String:
string := file upToEnd.
etc... Look at the Stream protocol, particularily in Stream and
PositionableStream.
Later,
Jon
--------------------------------------------------------------
Jon Hylands Jon at huv.com http://www.huv.com/jon
Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
http://www.huv.com
More information about the Squeak-dev
mailing list
|