I made a method that takes a File and a String. It replaces the file with a new file with that string as its contents.
This is what I made
In Java, the BufferWriter is very slow: Use the native methods directly, and call them as little as possible (give them as much data per call as you can).
try{
FileOutputStream file=new FileOutputStream(file);
file.write(content);
file.close();
}catch(Throwable e){
D.error(e);
}//try
Also, deleting the file can take a while (maybe it is being copied to the recycle bin first). Just overwrite the file, like in the above code.