Since I had a function to output bytes to a file (because I was doing something with bitmaps), I used it again to output a string, for example:
var filename: String = "/Users/me/path/to/file.txt";
var byteArray: ByteArray = new ByteArray ();
byteArray.writeUTFBytes (someString);
outFile (filename, byteArray);
private static function outFile (fileName: String, data: ByteArray): void {
var outFile: File = File.desktopDirectory; // dest folder is desktop
outFile = outFile.resolvePath (fileName); // name of file to write
var outStream: FileStream = new FileStream ();
// open output file stream in WRITE mode
outStream.open (outFile, FileMode.WRITE);
// write out the file
outStream.writeBytes (data, 0, data.length);
// close it
outStream.close ();
}
commanda
source share