Error when trying to delete a folder. Input is not valid Modified UTF-8

240 Views Asked by At

I have a folder with some files, one of those called 'dise�o.jpg'. When I try to remove the folder with the following sentence:

FileUtils.deleteDirectory(pathUnidadRenamed);

the app crashes throwing the following error:

  JNI DETECTED ERROR IN APPLICATION: 
  input is not valid Modified UTF-8: llegal start byte 0xa4
  string: 'dise�o.jpg'in call to NewStringUTF
  from java.lang.String[] java.io.File.listImpl(java.lang.String)

I already know that if I sign the app, it will not crash (but it will not remove the folder), but in this case I need to remove the folder and I do not have the possibility to rename the file due to customer requirements.

Does anyone know how to avoid that error? Any idea?

Thanks in advance.

1

There are 1 best solutions below

0
On

I finally solved my problem with Runtime.getRuntime().exec( rm -r + " " + path );