如何解决协程“不适当的阻塞方法调用”
suspend fun do(
fromFile: File,toFile: File
): File? = withContext(Dispatchers.IO) {
try {
FileOutputStream(toFile).use { <-- warning: FileOutputStream(toFile)
it.write(fromFile.readBytes())
}
return@withContext toFile
} catch (e: Exception) {
LogUtil.exception(TAG,e)
return@withContext null
}
}
在“ FileOutputStream(toFile).use {...}”行上,我收到以下警告: 我想知道为什么以及如何解决它。
我尝试了启动,异步,CoroutineScope,withContext等,但是没有用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。