java file.renameTo() does rename file but returns false. Why?

前端 未结 3 895
-上瘾入骨i
-上瘾入骨i 2021-01-02 18:23

The problem is that I need the file to move before the rest of my logic will work so when the method returns false I stop execution.

However, when I check on the fil

3条回答
  •  佛祖请我去吃肉
    2021-01-02 18:56

    Isn't it possible that you file has a Inputstream open somewhere but has not been closed and so the rename is not working. Try closing all open streams relevant to the file object before closing.

提交回复
热议问题