gpt4 book ai didi

flash - 如何从 Adob​​e AIR 中的文件流获取字节数组?

转载 作者:行者123 更新时间:2023-12-02 08:58:47 25 4
gpt4 key购买 nike

我阅读的内容有限(小 - 15 - 500 mb 文件)。我需要能够将所有文件字节放入一个字节数组中。所以我有一个功能:

        [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:遇到文件结尾。

如何从流中获取完整的字节数组并将其用作普通字节数组?

最佳答案

在查看文档一段时间后,我终于弄清楚了这一点。哇!

就我而言,我必须将 wav 文件作为我正在使用的类的 bytesArray 读取,这样我就可以在公共(public)范围内按需使用它。

var file:File = File.applicationDirectory.resolvePath("blip.wav");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var bytes:ByteArray = new ByteArray
fileStream.readBytes(bytes);
fileStream.close();

希望这对您有帮助,就像对我有帮助一样。我已经测试过它并确认它有效。

关于flash - 如何从 Adob​​e AIR 中的文件流获取字节数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2921708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com