code: public static String appendToPath(String basePath, String... pathElements) {
      Assert.notNull(basePath, "basePath cannot be null");
  
      String fileSeparator = (SystemUtils.isWindows() ? WINDOWS_FILE_SEPARATOR : File.separator);
  
      for (String pathElement : ArrayUtils.nullSafeArray(pathElements, String.class)) {
        if (StringUtils.hasText(pathElement)) {
          basePath = String.format("%1$s%2$s%3$s", basePath.trim(), fileSeparator, pathElement.trim());
        }
      }
  
      String fileSeparatorPattern = (SystemUtils.isWindows() ? WINDOWS_FILE_SEPARATOR_PATTERN
        : UNIX_FILE_SEPARATOR_PATTERN);
  
      return basePath.trim().replaceAll(fileSeparatorPattern, fileSeparator);
    }
docs: Creates a file system path by appending the array of path elements to the base path separated by
  {@link File#separator}.  If the array of path elements is null or empty then base path is returned.
  
  @param basePath base of the file system path expressed as a pathname {@link String}.
  @param pathElements array of path elements to append to the base path.
  @return the path elements appended to the base path separated by {@link File#separator}.
  @throws NullPointerException if basePath is null.
  @see java.io.File#separator