<read-from-stream>
Purpose/Function
Allows for incremental reading from an open stream. The stream object is to be placed into the environment, then accessed by this task (see WrapResource).
If EOF is encountered, or the number of bytes read is <= 0, the return value will be null
.
Attributes
NAME |
TYPE |
DEFAULT VALUE |
DESCRIPTION |
---|---|---|---|
stream |
|
(required) |
stream wrapping file, string or resource |
mark |
|
|
call |
reset |
|
|
call |
numBytes |
|
1024 |
number of bytes to attempt to read (= buffer size) |
returnString |
|
|
assign return value as string (otherwise, as array of bytes |
Elements
None.
ReturnValues
DEFAULT NAME |
TYPE |
DESCRIPTION |
---|---|---|
bytes |
|
result of the read |
Examples
<ogrescript> <wrap-resource name="stream" declare="true" type="input" resource="review.txt"/> <declare name="byteList"> </list> </declare> <for var="i" from="0" to="2"> <declare name="bytes"/> <read-from-stream stream="${stream}" returnString="true"> <return-value defaultName="bytes"/> </read-from-stream> <add collection="${byteList}" string="${bytes}"/> </for> <close toClose="${stream}"/> </ogrescript>