[newbie] My problem.
Karl Ramberg
karl.ramberg at chello.se
Sat Aug 19 13:04:11 UTC 2000
Jon Hylands wrote:
> 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
If you just need to read the file, open FileList and it will open in a
Workspace.
Karl
More information about the Squeak-dev
mailing list
|