resource failed to call close
生活随笔
收集整理的這篇文章主要介紹了
resource failed to call close
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在運行Android項目時,日志中會出現A resource failed to call close告警信息:
2021-05-26 11:26:52.564 11386-11401/com.xxx.example W/System: A resource failed to call close.這是由于文件輸入和輸出流在調用后沒有及時close導致的,需要在調用后手動close掉輸入輸出流
try {FileInputStream fis = new FileInputStream(path);FileChannel channel = fis.getChannel();ByteBuffer byteBuffer = ByteBuffer.allocate((int) channel.size());while ((channel.read(byteBuffer)) > 0) {// do nothing}byte[] dataByte = byteBuffer.array();channel.close(); //這里需要關閉channel,否則就會打印A resource failed to call closereturn dataByte;} catch (Throwable t) {}總結
以上是生活随笔為你收集整理的resource failed to call close的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开滦二中2021高考成绩查询,成人成才
- 下一篇: Hulu:视频广告系统中的算法实践