// 將 Uint8Array 轉換為 ArrayBuffer const arrayBuffer = uint8Array.buffer; const basePath = native.fileUtils.getWritablePath(); this.event.emit(NativeEvent.JSB_LOG, `寫檔測試`); native.fileUtils.writeDataToFile(arrayBuffer, basePath + '/hello.txt'); this.event.emit(NativeEvent.JSB_LOG, `讀檔測試`); const data = native.fileUtils.getDataFromFile(basePath + '/hello.txt'); // 將 ArrayBuffer 轉換為 Uint8Array const udata = new Uint8Array(data); // 將 Uint8Array 轉換回字串 const decoder = new TextDecoder(); const decodedString = decoder.decode(udata); this.event.emit(NativeEvent.JSB_LOG, `讀檔結果:${decodedString}`);