I have File object in Java which is a directory path:
C:\foo\foo\bar
…and I would like to change this to:
C:\foo\foo\newname
I’m don’t mean renaming the actual directory, but, simply modifying the path in the File object. Could someone show me how I can do this? Do I have to use string functions for this or is there some inbuilt Java function that I can use?
Thanks.
You can construct one File from another and get the parent directory of a file, combining these: