Ian Jiang wrote:
> I am still looking forward to your kind help
I was originally a little confused by your problem description, but on a
second read I understand that you want to know how to obtain an Integer
from a ReadStream.
If the stream contains text you can try to use Integer class>>readFrom:
but be aware that you have to position your stream at the beginning of
the integer (otherwise it returns 0 without advancing the stream; this
can easily create an endless loop). Writing can be done using the
#printOn: method of your number, this is called indirectly by using
#print: on the writeStream.
Text examples:
|rs|
rs := '1 2 3' readStream.
[rs atEnd] whileFalse: [
(Integer readFrom: rs) inspect.
rs skipSeparators].
|ws|
ws := String new writeStream.
1 to: 3 do: [ :n |
ws print: n; space].
ws contents inspect
Reading from binary file can also be done, but support is only available
for external streams (on files and sockets) and only for one endianness.
See for example implementers of #nextWord #nextWordPut: nextLong:
nextLongput: etc.
Sorry for the late response, we usually are a nicer bunch of people here ;-)
Reinout
-------
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc