Home> php教程> PHP开发> body text

Two methods for Flex to output files to local

高洛峰
Release: 2016-12-27 16:43:46
Original
1153 people have browsed it

I currently use two methods to output files to the local in flex, namely File and FieldRefreence

Example:

var exportString:String = "This is a test"

1. File output

var ff:File = File.desktopDirectory.resolvePath("Progress.CSV"); ff.addEventListener(Event.SELECT,exportCSVSelectedHandler); ff.browseForSave("选择路径"); private function exportCSVSelectedHandler(event:Event):void { var dir:String = event.target.nativePath; var writeStream:FileStream = new FileStream(); writeStream.open(new File(dir),FileMode.WRITE); var content:String = "jhfdklahflaksjdhflkasjhflaskjhlf\n"; writeStream.writeMultiByte(content,'utf-8'); writeStream.close(); }
Copy after login

2. FileReference output

var content:String = "jhfdklahflaksjdhflkasjhflaskjhlf\n"; var f:FileReference = new FileReference(); f.save(content,"1.csv");
Copy after login

The difference between File and FileReference is that File can specify the encoding format of the document, while FileReference is relatively simple to use

For more related articles on two methods of Flex outputting files to local area, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!