开发者

Open a file in flex 3

开发者 https://www.devze.com 2022-12-23 06:38 出处:网络
How can I create a .txt file using flex 3? A开发者_JAVA技巧nd I want to write some datas in to this file...... Is it possible? Any one can help me?

How can I create a .txt file using flex 3? A开发者_JAVA技巧nd I want to write some datas in to this file...... Is it possible? Any one can help me?

Thanks in advance.. Nimmy


//set File object    
var file:File=File.documentsDirectory;

    file=file.resolve(“myFile.txt”);
//set Stream object
    var stream:FileStream=new FileStream();
//set FileMode
    stream.open(file, FileMode.READ);
    var data:String= stream.readUTFBytes(Stream.bytesAvailable);
//close file
    stream.close();

different FILEMODE:

FileMode.APPEND: write only, append new data to the bottom of the file;

FileMode.READ: read only, file must exist;

FileMode.UPDATE: both read / write the data where positioned where you want;

FileMode.WRITE: write only , if file doesn't not exist, will be created otherwise will be overwritten;

0

精彩评论

暂无评论...
验证码 换一张
取 消