Check out example codes for "java rename file". It will help you in understanding the concepts better.

Code Example 1

File f1 = new File("oldname");
File f2 = new File("newname");

if(f2.exists)  {
  // Already exists
  return;
}

if(!f1.renameTo(f2))  {
  // no success
  return;
}

// oldname = pathname of the current file
// Bsp: resources/OldName.txt
// newname = pathname plus the new file
// Bsp: resources/NewName.txt

Learn ReactJs, React Native from akashmittal.com