resource failed to call close
生活随笔
收集整理的這篇文章主要介紹了
resource failed to call close
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在運(yùn)行Android項(xiàng)目時(shí),日志中會(huì)出現(xiàn)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.這是由于文件輸入和輸出流在調(diào)用后沒有及時(shí)close導(dǎo)致的,需要在調(diào)用后手動(dòng)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(); //這里需要關(guān)閉channel,否則就會(huì)打印A resource failed to call closereturn dataByte;} catch (Throwable t) {}總結(jié)
以上是生活随笔為你收集整理的resource failed to call close的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开滦二中2021高考成绩查询,成人成才
- 下一篇: 大话 TCP/IP