File.renameTo() fails

后端 未结 5 2168
半阙折子戏
半阙折子戏 2020-12-06 18:24

I have eclipse plugin jface application. A thread writes file via BufferedWriter. After writing is done I close the buffer after that I try to rename the file.

But

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 18:46

    We have had issues under Windows 7 with UAC and unexpected file permissions. File#canWrite will return true even though any attempts to perform file I/O will fail.

    1. Make sure the file you are trying to rename actually exists
    2. Make sure that the location you are attempting to write the file (or rename the file) to is accessible. We write a simple text file to the location, check to see if it exists and that it's contents is correct (we're paranoid) before we attempt any further I/O.

提交回复
热议问题