Java diamond chip of the day: renameTo()

jdavidb on 2008-03-06T15:30:45

You can't copy files, but you can rename/move files, which is really what I needed to do anyway. renameTo() is an instance method of the File class and takes another File object as a parameter.

Of course, whether or not it works across filesystem boundaries is platform-dependent in this beautifully portable language. You'll have to check the return value to see if it works.

On my system it doesn't, of course. Which is exactly why I needed it: due to weirdness of this particular mount I need to move a file into it rather than trying to create it and then write to it.

Thankfully I was able to fix some of the weirdness of the mount.