How To Rename File In Java

Home / Java / How To Rename File In Java


Java has a renameTo() method to rename a file.  This method is however really platform-dependent: you may successfully rename a file in *nix but failed in Windows. So, the return value (true if the file rename successful, false if failed) should always be checked to make sure the file is rename successful.

File.renameTo() Example