code: protected static String addFileNameToTargetPath(String sourcePath, String targetPath) {
          if (targetPath.endsWith("/")) {
              String filename = Paths.get(sourcePath).getFileName().toString();
              return targetPath + filename;
          }
          return targetPath;
      }
docs: If the target path is a directory (ends with "/"), add the file name from the source path to the target path.
  Otherwise, don't do anything
  
  Example:
  <p>
  sourcePath="/some/dir/file.pdf"<br>
  targetPath="/other/dir/"<br>
  returns: "/other/dir/file.pdf"
  </p>