Java Utililty Methods Path Normalize

List of utility methods to do Path Normalize

Description

The list of methods to do Path Normalize are organized into topic(s).

Method

StringnormalizeMediaPath(String hrefBaseUrl, String localMediaPath, String href)
Normalizes a HREF so it points to the local media Eclipse project
String result = "";
try {
    result = localMediaPath + href.split(hrefBaseUrl)[1];
} catch (Exception e) {
    result = localMediaPath + href;
return result;
StringnormalizeName(final String path, final boolean isDirectory)
normalize Name
String normalizedPath = path.replace(WIN_PATH_SEPARATOR, ARCHIVE_PATH_SEPARATOR);
if (isDirectory && !normalizedPath.endsWith(ARCHIVE_PATH_SEPARATOR)) {
    normalizedPath += ARCHIVE_PATH_SEPARATOR;
return normalizedPath;
StringNormalizeName(String absolutePath)
Normalize Name
String name = absolutePath;
for (String symbol : forbiddenSymbols) {
    if (!symbol.equals("\\"))
        name = name.replace(symbol, "");
return name;
StringnormalizePath(final String in)
normalize Path
String out = in;
if (in.endsWith("/")) {
    out = in.substring(0, in.length() - 1);
return out.replace("\\", "/");
StringnormalizePath(final String path)
Converts path characters from their native format to the "forward-slash" format expected within RPM files.
return path.replace('\\', '/');
StringnormalizePath(final String path)
Normalize path.
return path.replace("%7E", "~").replace(" ", "%20");
StringnormalizePath(final String path)
Removes any extra path separators and converts all from back slashes to forward slashes.
return path != null ? path.replaceAll(BACK_SLASH_NORMALIZATION_PATTERN, FORWARD_SLASH)
        .replaceAll(FORWARD_SLASH_NORMALIZATION_PATTERN, FORWARD_SLASH) : null;
StringnormalizePath(final String path)
normalize Path
if (path.endsWith("/") || path.endsWith("\\")) {
    return normalizePath(path.substring(0, path.length() - 1));
} else {
    return path.replaceAll("/+", "/").replaceAll("\\\\+", "\\\\");
StringnormalizePath(final String... path)
normalize Path
if (path == null || path.length < 1) {
    return "/";
final StringBuilder sb = new StringBuilder();
int idx = 0;
parts: for (String part : path) {
    if (part == null || part.length() < 1 || "/".equals(part)) {
        continue parts;
...
StringnormalizePath(String _path, boolean _appendFinalSeparator)
Normalize a file system path expression for the current OS.
if (_path == null) {
    return _path;
String path = _path.replace("\\", FILE_SEPARATOR).replace("/", FILE_SEPARATOR);
if (_appendFinalSeparator && !path.endsWith(FILE_SEPARATOR)) {
    path += FILE_SEPARATOR;
return path;
...