Skip to content

Instantly share code, notes, and snippets.

@amacdougall
Created March 13, 2012 15:09
Show Gist options
  • Save amacdougall/2029335 to your computer and use it in GitHub Desktop.
Save amacdougall/2029335 to your computer and use it in GitHub Desktop.
Quick and dirty AIR filestream test
package {
// imports
import flash.display.*;
import flash.events.*;
import flash.filesystem.*;
import flash.text.TextField;
/**
* Quick and dirty AIR file stream test.
*/
public class AirFileStream extends Sprite {
/* INSTANCE VARIABLES */
/* INSTANCE METHODS */
public function AirFileStream() {
testFileRead();
}
public function testFileRead():void {
var file:File = new File(File.userDirectory.resolvePath("test.txt"));
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var text:String = fileStream.readMultiByte(file.size, File.systemCharset);
trace("Read file contents:");
trace(text);
fileStream.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment