better example
authorsr
Thu, 15 Feb 2007 15:46:40 +0100
changeset 1847 5364b697ad8f
parent 1846 3be8e3d770f0
child 1848 a46bf4d43b42
better example
ZipStream.st
--- a/ZipStream.st	Mon Feb 12 12:31:49 2007 +0100
+++ b/ZipStream.st	Thu Feb 15 15:46:40 2007 +0100
@@ -9,7 +9,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-
 "{ Package: 'stx:libbasic2' }"
 
 CompressionStream subclass:#ZipStream
@@ -86,19 +85,33 @@
 
 examples
 "
-								[exBegin]
-    |compressed zipStream|
+                                                                [exBegin]
+    |compressedDataStream zipStream compressedData uncompressedData|
+
+    compressedDataStream := #[] writeStream.
+    zipStream := ZipStream writeOpenOn:compressedDataStream.
+    zipStream nextPutAll:'hallo Welt'.
+    zipStream close.
+
+    compressedData := compressedDataStream contents.
+
+    zipStream := ZipStream readOpenOn:(compressedData readStream).
 
-self halt.
-    compressed := #[] writeStream.
-    zipStream := self writeOpenOn:compressed.
-    zipStream nextPutAll:'This is some text 1234567890'.
-    zipStream flush.
-    self information:'Compressed size: ', compressed contents size printString.
-self halt.
-    zipStream := self readOpenOn:compressed contents readStream.
-    self information:zipStream contents.
-								[exEnd]
+    zipStream notNil ifTrue:[
+        |stream c|
+
+        stream := '' writeStream.
+
+        [ (c := zipStream next) notNil ] whileTrue:[
+            stream nextPut:c
+        ].
+        stream close.
+        uncompressedData := stream contents.
+    ].
+    ^ uncompressedData
+                                                                [exEnd]
+
+
 "
 ! !
 
@@ -713,7 +726,7 @@
 !ZipStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.27 2007-01-17 13:47:40 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.28 2007-02-15 14:46:40 sr Exp $'
 ! !
 
 ZipStream initialize!