Java renameTo in content folder

Just try using Java to rename the root of the folder tree.

Using File.renameTo () only works on Windows if there is no content in the folder. I can't seem to find if this is the expected behavior or not. This does not seem to be mentioned in the docs.

I need to use the recursive process of copying \ folder files and then delete the original, but this is pretty intense than I had hoped for in the folder tree, where each node could potentially have hundreds of children.

Java 7 seems to have Path.moveTo (), but I can't use 7 yet.

Am I trying to do this in a dirty way, or is there a way to change the root folder name?

Thank.

+3
source share
1 answer

You can rename content folders in windows.
However, if one of the files in the folder is open for output, then there may be a file lock that prevents the renaming of the parent folder.

Locate file locks with the excellent Process Explorer from sysinternals.
It looks like a task manager on steroids.

+7
source

Source: https://habr.com/ru/post/1767775/


All Articles