Rename the new file for the old file and remove the old file



  • I have two files. We need to rename the new file in the old name and remove the old file.

    I tried to do this:

    boolean successful = tempFile.renameTo(inputFile);
    

    It didn't work.



  • Of course not! And Java doesn't have to. You're trying to file two files with the same name in one folder, the operating system won't let you.

    We need to copy the name of the old file, remove it and rename the new one.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2