code: public static String formatFilePath(String filePath) {
          if (filePath == null) {
              return null;
          }
          return normalizePath(filePath.replaceAll("//*", "/").replaceAll("\\*", "\\").replaceAll("/", "\\" + System.getProperty("file.separator")).replaceAll("\\\\", "\\" + System.getProperty("file.separator")), System.getProperty("file.separator").equals("/"));
  
      }
docs: Replaces all "\" and "/" in the specified file path by
  <code>file.separator</code> system property.
  
  @param filePath the original file path.
  @return the formatted file path.