public static Path moveFile(FileSystem fs, Path srcFile, Path destDir, String destFileName)
      throws IOException, HiveException {
    Path dstFilePath = new Path(destDir, destFileName);
    if (fs.exists(dstFilePath)) {
      ParsedOutputFileName parsedFileName = ParsedOutputFileName.parse(destFileName);
      int suffix = 0;
      do {
        suffix++;
        if (parsedFileName.matches()) {
          dstFilePath = new Path(destDir, parsedFileName.makeFilenameWithCopyIndex(suffix));
        } else {
          dstFilePath = new Path(destDir, destFileName + "_" + suffix);
        }
      } while (fs.exists(dstFilePath));
    }
    if (!fs.rename(srcFile, dstFilePath)) {
      throw new HiveException("Unable to move: " + srcFile + " to: " + dstFilePath);
    }
    return dstFilePath;
  }
Rename src to dst, or in the case dst already exists, move files in src to dst. If there is an
existing file with the same name, the new file's name will be generated based on the file name.
If the file name confirms to hive managed file NNNNNN_Y(_copy_YY) then it will create NNNNN_Y_copy_XX
else it will append _1, _2, ....
@param fs
         the FileSystem where src and dst are on.
@param srcFile
         the src file
@param destDir
         the target directory
@param destFileName
         the target filename
@return The final path the file was moved to.
@throws IOException
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java