惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
量子位
G
Google Developers Blog
J
Java Code Geeks
N
Netflix TechBlog - Medium
博客园 - 聂微东
宝玉的分享
宝玉的分享
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
雷峰网
雷峰网
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss

博客园 - Ray Lynn

Google Chrome 源码下载 什么是SAAS? QQ盗号木马原理 WindowsSockets 错误码 js操作cookies类 使用 Microsoft SOAP Toolkit 2.0 建立安全 Web 服务 历史上最强的代码 饭否,唧歪们MSN、QQ、GTalk机器人实现原理及代码 这是比月读还强的幻术!! - Ray Lynn - 博客园 .net 中的伪静态方式. 来自 Discuz!NT 伪静态网页的实现 ACCESS 创建表及索引方式 VB6 判断网络是否正常类 眼保健操 面向服务的面向业务基础 VB6编程中如何获取硬盘分区信息 原味香菇片蒸鸡腿 定制特性学习笔记 [转]C#中的定制特性(Attributes)
使用 flex air 读写文件 - Ray Lynn
Ray Lynn · 2008-11-23 · via 博客园 - Ray Lynn

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" width="429" height="376">
<mx:Script>
<![CDATA[
import mx.messaging.AbstractConsumer;

private function init():void{

}

private function onOpen():void
{
var file:File = new File();
file.browseForOpen("Select a text file",[new FileFilter("text file","*.txt")]);
file.addEventListener(Event.SELECT,onFileSelect);
}

private function onFileSelect(e:Event):void{
var fs:FileStream = new FileStream();
txtPath.text = File(e.target).nativePath;
fs.open(File(e.target),FileMode.READ);
txtContent.text = fs.readUTFBytes(fs.bytesAvailable);
fs.close();
}

private function Save():void{
var fs:FileStream = new FileStream();
fs.open(new File(txtPath.text),FileMode.WRITE);
fs.writeUTFBytes(txtContent.text);
fs.close();
}
]]>
</mx:Script>
<mx:TextInput id="txtPath" x="10" y="10" width="321"/>
<mx:Button id="btnOpen" x="339" y="10" label="Open" click="onOpen()"/>
<mx:TextArea id="txtContent" x="10" y="40" width="394" height="276"/>
<mx:Button x="339" y="324" label="Save" click="Save()"/>
</mx:WindowedApplication>

虽然读写过程都正常,但遇到中文字符时就会出现乱码,不知何因.