中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何使用HarmongOS的异步能力实现单次I/O任务逻辑?
微信扫码分享
import { fileIo } from '@kit.CoreFileKit' import { BusinessError } from '@kit.BasicServicesKit'; async function write(data: string, file: fileIo.File): Promise<void> { fileIo.write(file.fd, data).then((writeLen: number) => { console.info('write data length is: ' + writeLen) }).catch((err: BusinessError) => { console.error(`Failed to write data. Code is ${err.code}, message is ${err.message}`); }) }