Today's screencast is a basic introduction to file handling in Smalltalk, looking at class Filename, and at basic Stream protocol.
Here's the code I used in the short examples in the screencast - The #nextLine message is part of the NetClients package - when I did the recording, I didn't notice that. To get that code, load the NetClients parcel:
"Filename is your entry point into file handling"
(Filename named: '.') directoryContents.
"Read line by line"
list := List new.
stream := 'lines.txt' asFilename readStream.
[stream atEnd]
whileFalse: [list add: stream nextLine].
stream close.
"more manually, to show stream protocol"
list := List new.
stream := 'lines.txt' asFilename readStream.
[[stream atEnd]
whileFalse: [| next|
next := stream upTo: Character cr.
list add: next]]
ensure: [stream close].
You can download the video directly here. If you like this kind of video, why not subscribe to "Smalltalk Daily"?
We'll be doing the podcast with David Buck tomorrow - he's recently been working on upgrading some VisualWorks users from older versions (including version 2.5.x) to the latest release. Listen live on justin.tv
Dave Buck reports that Dorin Sandu will be talking about Smalltalk and Cocoa in Ottawa this month:
We will provide an overview of model-view-controller as implemented by Cocoa, introduce key-value coding, key-value observing, key-value binding, and review some of the provided controllers and views. We will illustrate all these concepts through several example applications implemented in Smalltalk.
Follow the link for location details; it's happening at 6 PM April 14
To listen now, you can either download the mp3 edition, or the AAC edition. The AAC edition comes with chapter markers. You can subscribe to either edition of the podcast directly in iTunes; just search for Smalltalk and look in the Podcast results. You can subscribe to the mp3 edition directly using this feed, or the AAC edition using this feed using any podcatching software.
To listen immediately, use the player below:
If you like the music we use, please visit Josh Woodward's site. We use the song Effortless for our intro/outro music. I'm sure he'd appreciate your support!
If you have feedback, send it to smalltalkpodcasts@cincom.com - or visit us on Facebook or Ning - you can vote for the Podcast Alley, and subscribe on iTunes. If you enjoy the podcast, pass the word - we would love to have more people hear about Smalltalk!