I am trying to rename files in same Windows directory using Java -
Before: -
C:/Temp/abG.txt
After: -
C:/Temp/ABG.TXT
I have tried using file.renameTo
but that did not work. Now I am trying to use -
Path source = file.toPath();
Files.move(source, source.resolveSibling(file.getName().toUpperCase()));
Still no luck. Please help.
Finally issue is resolved.
It seems
file.renameTo
works fine on Windows. The path I mentioned was wrong, rectified it and code worked.I was using path as
C:/Temp/Folder
it should beC:/Temp/Folder/
Try the following
I haven't tried running but this logically should work.
Hope this helps.