public static void copyFileWithMD5Check(final File sourceFile, final File targetDir)
      throws IOException {
    final String sourceFileName = sourceFile.getName();
    final File targetFile = new File(targetDir, sourceFileName);
    if (targetFile.exists()) {
      if (sourceFile.length() == targetFile.length()) {
        copyWithMD5Check(sourceFile, targetDir, targetFile);
        return;
      }
      copyFileRenameWithSize(sourceFile, targetDir);
    } else {
      try {
        Files.createDirectories(targetDir.toPath());
      } catch (IOException e) {
        LOGGER.warn("failed to create target directory: {}", targetDir.getAbsolutePath());
        throw e;
      }

      Files.copy(
          sourceFile.toPath(),
          targetFile.toPath(),
          StandardCopyOption.REPLACE_EXISTING,
          StandardCopyOption.COPY_ATTRIBUTES);
    }
  }
Transfer bytes to human-readable string. Copy from <a
href="https://stackoverflow.com/a/3758880">stackoverflow</a>.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java