public static File renameFile(File file,String newName){
  String absolutePath=file.getAbsolutePath();
  String fileName=file.getName();
  String newAbsolutePath=absolutePath.substring(0,absolutePath.lastIndexOf(fileName)) + newName;
  return new File(newAbsolutePath);
}

public static File renameFile ( File file , String newName ) { String absolutePath = file . getAbsolutePath ( ) ; String fileName = file . getName ( ) ; String newAbsolutePath = absolutePath . substring ( 0 , absolutePath . lastIndexOf ( fileName ) ) + newName ; return new File ( newAbsolutePath ) ; }
change the name of the file
