Android文件操作报open failed: EBUSY (Device or resource busy)
Android删除文件后重新创建时偶尔出现 open failed: EBUSY (Device or resource busy)错误,该错误是Android系统的一个bug,大概的意思类似于windows的“改文件正在被使用”。产生这个错误的原因是Android在删除文件后没有及时释放文件锁,导致文件在重新创建时仍然处于被某一进程占用的状态。解决的方法是:在删除文件之前对该文件进行重命名,这样可以保证在删除文件时系统持有的文件锁是重命名之后的文件锁。代码可以这样写:
final File to = new File(file.getAbsolutePath() + System.currentTimeMillis());
file.renameTo(to);
to.delete();
最后再重新创建文件就可以了。
Android文件操作报open failed: EBUSY (Device or resource busy)的更多相关文章
- android java.io.IOException: open failed: EBUSY (Device or resource busy)
今天遇到一个奇怪的问题, 测试在程序的下载界面,下载一个文件第一次下载成功,删除后再下载结果下载报错, 程序:file.createNewFile(); 报错:java.io.IOException: ...
- read()、write()返回 Input/output error, Device or resource busy解决
遇到的问题,通过I2C总线读.写(read.write)fs8816加密芯片,报错如下: read str failed,error= Input/output error! write str fa ...
- android 文件操作类简易总结
android 文件操作类(参考链接) http://www.cnblogs.com/menlsh/archive/2013/04/02/2997084.html package com.androi ...
- Linux下rm -rf删除文件夹报错_ Device or resource busy
1.错误信息 rm: cannot remove `speechd-centos_6.2-prtl-pred-mf34/modules/t2p/py/third/g2p/.nfs00000000039 ...
- Docker - 解决在容器内删除和主机映射的目录而报错 rm: cannot remove 'webapps': Device or resource busy 的问题
问题背景 docker run -d --name tomcat7 -v /usr/local/tomcat/webapps:/usr/local/tomcat/webapps tomcat:7 使用 ...
- mount: mounting proc on /proc failed: Device or resource busy
/********************************************************************** * mount: mounting proc on /p ...
- WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
在 mkfs.ext4 /dev/sda2 格式化硬盘空间时,可能出现这种错误. had this situation at office where I was told to re-partiti ...
- docker中执行sed: can't move '/etc/resolv.conf73UqmG' to '/etc/resolv.conf': Device or resource busy错误的处理原因及方式
错误现象 在docker容器中想要修改/etc/resolv.conf中的namesever,使用sed命令进行执行时遇到错误: / # sed -i 's/192.168.1.1/192.168.1 ...
- Docker之rm: Device or resource busy
docker 容器里 rm -rf /data 提示: rm: cannot remove ‘/data’: Device or resource busy 原因: 在建立容器的时候做了相应目录的挂载 ...
随机推荐
- jsp之${CTX}理解
jsp之${CTX} 根据自己的需要选择以下标签. <%@ taglib uri="/struts-tags" prefix="s"%> <% ...
- BZOJ1452 count (树状数组)
一道比较水的二维树状数组,开100个即可,只有100种颜色还是比较EZ的. Program BZOJ1452; ; maxc=; ..maxn,..maxn,..maxc] of longint; f ...
- Linux下汇编语言学习笔记71 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- C. Painting Fence 分治
memory limit per test 512 megabytes input standard input output standard output Bizon the Champion i ...
- 最小生成树 C - Building a Space Station
You are a member of the space station engineering team, and are assigned a task in the construction ...
- kendo grid 点击更新没有反映
因为没有在dataSource上写schema schema: { model: { id: "DeptId", fields: { CompanyId: { editable: ...
- 生成sde
/// <summary> ///获取保存的SDE文件 /// </summary> /// <param name="sdePath">< ...
- 走进windows编程的世界-----画图相关
Windows画图 1 图形绘制 1.1 图形绘制的方式 获取到画图句柄-设备描写叙述表(DC),使用对应的画图的API,在设备上绘制图形. 1.2 颜色 ...
- Spring MVC JSON自己定义类型转换(续)
前面提到了两种转换类型的方法(Spring MVC JSON自己定义类型转换),这里针对Json转换提供一种更简便的方法. 通过配置全局的日期转换来避免使用麻烦的注解. 首先用到了一个简单的日期工具类 ...
- 约瑟夫环问题(猴子选大王)PHP版
约瑟夫斯问题问题有时候也被描述成猴子选大王问题,题目如下.(最后会贴上约瑟夫问题的来历) 一群猴子排成一圈,按1,2,…,n依次编号. 然后从第1只开始数,数到第m只,把它踢出圈,从它后面再开始数,再 ...