Prev | Current Page 591 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

..catch
block not releasing the exception.
readBytes
The second way to read characters from a stream is by extracting them using the readBytes method.
This method accepts three parameters; a buffer, the starting location in the buffer to write data, and the
length of bytes to extract:
var charactersRead = stream.readBytes( strBuffer, intStart, intLength );
The buffer is a string of a preset length, which is passed to the readBytes method and used as a container
for the bytes you want to extract. You can use an existing string for this, or simply use the makeString
method in the neko.Lib class. It is passed by reference, so once you have made a call to the readBytes
method, you will then likely use the string elsewhere in the application, or store it in another medium.
When specifying the start location and length of bytes within the buffer, it is important to make sure that
the sum of both values is not greater than the length of the buffer. Failure to enforce this will cause the
readBytes method to fail.


Pages:
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603