. .

st4u

ST 4U 289: Reading Binary FIles in VA Smalltalk

September 28, 2012 10:23:47.057

Today's Smalltalk 4 You looks at reading binary formatted files in VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

binary files.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at how you open files in binary mode in VA Smalltalk. To get started, look at the code below:


"specify that we are reading characters"
stream := CfsReadFileStream open: 'abt.ini'.
stream isCharacters: true.
text := stream contents.
stream close.
^text.



"specify binary"
stream := CfsReadFileStream open: 'snow1.jpg'.
stream isBytes: true.
bytes := stream contents.
stream close.
^bytes.

You would not typically use #isCharacters: - that's the default. Use #isBytes: to read the raw bytes into a byte array.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , , ,

Enclosures:
[st4u289-iPhone.m4v ( Size: 2143061 )]

posted by James Robertson

 Share Tweet This