-2

I keep getting an IOException and I don't understand what it means.

Code (pseudo):

File file = new File("/filepath/");
fos = new FileOutputStream(file);
String str =  String.format("0");
fos.write(str.getBytes());
fos.close();

Error:

W/System.err( 1794): java.io.IOException: write failed: EBUSY (Device or resource busy)
W/System.err( 1794):  at libcore.io.IoBridge.write(IoBridge.java:452)
W/System.err( 1794):  at java.io.FileOutputStream.write(FileOutputStream.java:187)
W/System.err( 1794):  at java.io.OutputStream.write(OutputStream.java:82)

What does the "write failed: EBUSY (Device or resource busy)" part mean?

  • possible duplicate of [open failed: EBUSY (Device or resource busy)](http://stackoverflow.com/questions/11539657/open-failed-ebusy-device-or-resource-busy) – glethien Sep 14 '15 at 09:24

2 Answers2

1

Sounds like the file you wanted to open is already in use. There are some related questions here on SO.

open failed: EBUSY (Device or resource busy)

May due to debugging and starting you app all over again, the file is still in use.

Community
  • 1
  • 1
glethien
  • 2,440
  • 2
  • 26
  • 36
0

If you search it online you will find that either a few processes use the file or you deleted the file but not the reference. You can try search for existence of the file before trying to write or do something with the file. My solution would be to search for the existence of the file before doing something on it and if it exists delete and create new or something like that.
open failed: EBUSY (Device or resource busy)

Community
  • 1
  • 1
Andrei T
  • 2,985
  • 3
  • 21
  • 28