Prev | Current Page 589 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


For example, if you wish to stream data out of the file, then you need to create a FileInput stream
object, while the FileOutput stream will write to the file. Personally, we often get confused over which
class is which, as to me, FileInput would assume inputting data into the file, though you could look at
this either way.
In terms of syntax, it matters little whether you are creating a stream for writing or for reading. Both
methods require a similarly structured method call and can be used in the same fashion. This makes
sense, as one file ??™ s output could quite possibly become another file ??™ s input.
Reading Data from a Stream
To create a FileInput stream from a file, you use neko.io.File.read . This method accepts the path
to the file as a string and a Boolean depicting whether or not the file contains binary data:
var stream = neko.io.File.read( ???pathToMyFile.zip???, true );
readChar
Once you have your returned FileInput stream, you then have full control over where you direct its
throughput.


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