如何从文件流在Adobe AIR的ByteArray? [英] How to get a bytearray from file stream in Adobe AIR?

查看:230
本文介绍了如何从文件流在Adobe AIR的ByteArray?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读的限制(小 - 15 - 500 MB的文件)。 我需要能够把所有文件的字节到一个单一的字节组。 所以我有一个函数:

I read limited (small - 15 - 500 mb files). I need to be able to put all file bytes into one single bytearray. So I have a function:

        [Bindable]
        public var ba:ByteArray = new ByteArray;
        //.... code ....//
        protected function fileOpenSelected(event:Event):void
        {
            currentFile = event.target as File;
            stream = new FileStream();
            stream.openAsync(currentFile, FileMode.READ);
            stream.readBytes(ba);
            stream.close();

                            MyFunction(ba);
        }

但它不工作=( - 给我的错误:错误#2030:文件结尾遇到

But it does not work=( - gives me Error: Error #2030: End of file was encountered.

如何从流获取完整的字节组使用它作为普通的ByteArray?

How to get a full bytearray from stream to use it as normal bytearray?

推荐答案

不点一的FileStream ,你没有一个正常的的ByteArray ,但异步读?它实现<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/IDataInput.html"相对=nofollow> 的IDataInput ,让您可以从它只要方bytesAvailable 是更大的阅读比0。

isn't the point of a FileStream that you don't have a normal ByteArray, but read asynchronously? It implements IDataInput, allowing you to read from it as long as bytesAvailable is bigger than 0.

这是每一个进步事件,你只需的ReadBytes 到输出的ByteArray ,一旦你得到一个完整的事件,你可以使用它。

on every progress event, you can just readBytes into an output ByteArray and once you get a complete event, you can use it.

格尔茨
back2dos

greetz
back2dos

这篇关于如何从文件流在Adobe AIR的ByteArray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆