Prev | Current Page 593 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

readAll works similarly to
the getContent method of the neko.io.File class, at least in terms of its general effect. Under the
307
Chapter 11: Performing Server-Side Trickery
hood, and in terms of its usefulness, the readAll method is completely different. The getContent
method is explained next.
As you can probably guess, the readAll method allows the application to read all bytes from a stream.
If necessary, you can supply an optional parameter specifying the maximum size of the buffer you are
streaming to, but under most circumstances, this shouldn ??™ t be necessary.
class ReadAll
{
public static function main()
{
var stream = neko.io.File.read( ???example.txt???, false );
var str : String = stream.readAll();
stream.close();
neko.Lib.println( str );
}
}
Directly Reading Data
Sometimes, you might consider reading data through the use of a stream object as a bit overkill. For
instance, if you just want to read the contents of a text file for display in a web page or console. At such
times, you are better off using the getContent method of the File class.


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