Prev | Current Page 597 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

print( err );
}
stream.close();
}
}
write
As with reading from a stream, writing data to a stream also has a simple write - all approach, using the
write method. write simply outputs an entire string to the given stream.
class WriteAll
{
public static function main()
{
var stream = neko.io.File.write( ???example.txt???, false );
var str = ???abcdefghijklmnopqrstuvwxyz???;
try
{
stream.write( str );
stream.flush();
}
catch ( err : Dynamic)
{
//neko.Lib.print( err );
}
stream.close();
}
}
Traversing a Stream
When you are dealing with bytes in a stream, it is possible to move the current play head, as it were, to a
different location for random byte access. haXe provides two methods to aid in this: tell and seek .
tell accepts no parameters and returns the current location of the marker in the stream as an integer:
var position = stream.tell();
Seek , on the other hand, allows you to reposition the marker based on a given enumerator flag:
stream.seek( intMove, seekCur );
310
Part II: Server Side, JavaScript, and Flash: Oh My!
The first parameter is the number of spaces you want to move the marker.


Pages:
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609