Why doesn't File.renameTo(...)
create sub-directories contained in the destination file path?
For instance,
File source = new File(System.getProperty("user.dir") +
"/src/MyFolder/MyZipFolder.zip");
File dest = new File(System.getProperty("user.dir") +
"/src/MyOtherFolder/MyZipFolder.zip");
System.out.println(source.renameTo(dest));
Since MyOtherFolder
does not exist, this will always return false
. In order for this to work, I have to ensure that all sub-directories exist either by creating them programmatically(i.e. mkdirs()
), or manually. Is there a reason why this functionality was not included in this method?