Stream questions and answers

Stéphane Ducasse stephane.ducasse at univ-savoie.fr
Sun Jun 19 12:11:32 UTC 2005


I'm trying to save a jpeg file on my disc. I tried a lot of different  
classes but could not get something worki ng. So I came back with the  
simplest idea I got



| contents string stream |
contents := 'http://www.bedetheque.com/Couvertures/ 
AntonBlake1_05042005.jpg' asUrl retrieveContents.
string := (FileDirectory default fullName, FileDirectory default  
pathNameDelimiter asString,  'Couvertures', FileDirectory default  
pathNameDelimiter asString, 'Anton.jpg' ).
stream := string asFileName writeStream.
stream nextPutAll: contents content.
stream close

I could not understand why this was not working....Nothing was put in  
the file.

Then after losing 30 min. I found the solution

| contents string stream |
contents := 'http://www.bedetheque.com/Couvertures/ 
AntonBlake1_05042005.jpg' asUrl retrieveContents.
string := (FileDirectory default fullName, FileDirectory default  
pathNameDelimiter asString, 'Anton.jpg' ).
stream := FileStream newFileNamed: string.
stream nextPutAll: ((RWBinaryOrTextStream with: contents content)  
binary) contents.
stream close



More information about the Squeak-dev mailing list