--- a/WriteStream.st Mon Feb 19 17:29:54 2018 +0100
+++ b/WriteStream.st Tue Feb 20 01:07:35 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -179,6 +181,30 @@
"
!
+readStream
+ "return a readstream on the current contents;
+ that is: if more is written to the stream in the meantime,
+ the readStream will NOT show it.
+ To avoid copying the contents, a readStream with a readLimit
+ is created. In the hope, that noone repositions and rewrites the
+ underlying writeStream.
+ If that leads to problems, you should use contents readStream."
+
+ ^ ReadStream on:collection from:1 to:self position.
+
+ "
+ |w r|
+
+ w := WriteStream on:(String new).
+ w nextPutAll:'12345'.
+ r := w readStream.
+ w nextPutAll:'abc'.
+ w nextPutAll:(r upToEnd).
+ w nextPutAll:'def'.
+ w contents.
+ "
+!
+
reset
"reset the stream; write anew.
See the comment in WriteStream>>contents"