A just-deleted index file can still be held by the system, so createNewFile() may fail right after deletion. Retry a few times with a short delay, waiting for the old file to disappear first.
A just-deleted index file can still be held by the system, so createNewFile() may fail right after deletion. Retry a few times with a short delay, waiting for the old file to disappear first.