@Component
export struct ArrayBufferConversionArray {
@State fileLength: number = 10;
private tempData: number[] = [];
aboutToAppear(): void {
// Convert ArrayBuffer to a number array
let arrayBuffer: ArrayBuffer = new ArrayBuffer(this.fileLength);
let dataView: DataView = new DataView(arrayBuffer);
for (let index = 0; index < this.fileLength; index++) {
this.tempData[index] = dataView.getInt8(index);
}
console.info(this.tempData.toString());
}
build() {
RelativeContainer() {
Text(this.tempData.toString())
.id('ArrayBufferHelloWorld')
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
}
.height('100%')
.width('100%')
}
}