Prev | Current Page 595 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

io.File.write( ???pathToFile.txt???, boolIsBinary );
308
Part II: Server Side, JavaScript, and Flash: Oh My!
While appending to an existing file requires:
var stream = neko.io.File.append( ???pathToFile.txt???, boolIsBinary );
The Boolean value in the second parameter should be set to false if the file will contain ASCII data, or
true if it will contain binary.
writeChar
Once you have your FileOutput object, you can now choose to write bytes or characters to your stream.
The writeChar method adds characters to the end of the stream data. It accepts a single parameter; the
integer of the character to add:
stream.writeChar( intChar );
To convert a character from a string to an integer, use the Std.ord method:
class WriteChar
{
public static function main()
{
var stream = neko.io.File.write( ???example.txt???, false );
var str = ???abcdefghijklmnopqrstuvwxyz???;
var pos = 0;
while ( pos < = str.length )
{
try
{
stream.writeChar( Std.ord( str.charAt( pos ) ) );
}
catch ( err : Dynamic)
{
//neko.


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