Stream API Functions: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 25.x)
Zur Navigation springen Zur Suche springen
Inhalt gelöscht Inhalt hinzugefügt
Zeile 67: Zeile 67:
''aStream'' '''nextPut:''' ''someElement''
''aStream'' '''nextPut:''' ''someElement''
''aStream''.'''nextPut'''(someElement) [JS]
''aStream''.'''nextPut''' (''someElement'') [JS]


Example:
Example:
Zeile 73: Zeile 73:
s nextPut: $a.
s nextPut: $a.
s nextPut: $b.
s nextPut: $b.
s close.

===== nextPutAll: =====
Appends (writes) a number of elements to the stream.

''aStream'' '''nextPutAll:''' ''aCollectionOfElements''
''aStream''.'''nextPutAll''' (''aCollectionOfElements'') [JS]

Example:
s := 'data.txt' asFilename writeStream.
s nextPutAll: 'abc'.
s close.
s close.



Version vom 4. Dezember 2019, 13:50 Uhr

This document lists most useful (and most often needed) functions. Be aware, that there are many more to be found in either the class references or via the builtin class browser.

Reference: Stream and ExternalStream and Socket

Back to Useful API Functions

Creation

Internal Streams
aCollection readStream
aCollection writeStream
External Streams
pathString asFilename readStream
pathString asFilename writeStream
pathString asFilename appendingWriteStream
Socket newTCPclientToHost:hostNameOrAddress port:aPortOrServiceName

Reading

next

Returns the next element from the stream.

aStream next

aStream.next() [JS]

Example:

 s := 'data.txt' asFilename readStream.
 s next.
 => character
next:

Returns the next n elements from the stream.

aStream next: count

aStream.next(count) [JS]

Example:

 s := 'data.txt' asFilename readStream.
 s next:5.
 => string-of-5-chars
nextByte

Returns the next character as a byte valued integer. Only valid for character streams.

nextBytes:

Returns the next n characters as a byteArray. Only valid for character streams.

Writing

nextPut:

Appends (writes) an element to the stream.

aStream nextPut: someElement

aStream.nextPut (someElement) [JS]

Example:

 s := 'data.txt' asFilename writeStream.
 s nextPut: $a.
 s nextPut: $b.
 s close.
nextPutAll:

Appends (writes) a number of elements to the stream.

aStream nextPutAll: aCollectionOfElements

aStream.nextPutAll (aCollectionOfElements) [JS]

Example:

 s := 'data.txt' asFilename writeStream.
 s nextPutAll: 'abc'.
 s close.
nextPutByte:

Appends a byte valued integer to the stream. Only valid for character streams.



Copyright © 2014-2024 eXept Software AG