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

Stringnormalize(String pathname, int len, int off)
normalize
if (len == 0)
    return pathname;
int n = len;
while ((n > 0) && (pathname.charAt(n - 1) == '/'))
    n--;
if (n == 0)
    return "/";
StringBuilder sb = new StringBuilder(pathname.length());
...
intnormalize_color_path(int eff_color_path)
Rasterizer inlines
eff_color_path &= ~((1 << 26) | (1 << 27));
return eff_color_path;
StringnormalizeAllSeparators(String path)
Replaces forward and backward slashes, not only system-specific separators, with a forward slash.
return path.replaceAll("[/\\\\]+", "/");
StringnormalizeBasePath(String basePath)
normalize Base Path
String normalized = basePath;
while (normalized.endsWith("/")) {
    normalized = normalized.substring(0, normalized.length() - 1);
return normalized;
StringnormalizeDbPath(String databasePath)
normalize Db Path
databasePath = databasePath.replace('\\', '/').toLowerCase();
if (!databasePath.startsWith("/")) {
    databasePath = "/".concat(databasePath);
return databasePath;
StringnormalizeDotSegment(String path)
normalize Dot Segment
while (path.startsWith("/./") || path.startsWith("/../")) {
    path = path.replaceFirst("/[\\.]+/", "/");
return path;
StringnormalizedPath(String original)
Replaces all backslashes with slash char.
return original.replaceAll("\\\\", "/");
StringnormalizeFileSystemPath(String path)
Convert Windows path to Unix
if (path != null) {
    String osname = System.getProperty("os.name");
    if (osname.toLowerCase().contains("windows")) {
        return path.replace('\\', '/');
return path;
StringnormalizeFullPath(String path)
Normalizes full path names by resolving .
if (path != null) {
    int index;
    StringBuilder buffer;
    char ch;
    path = path.replace('\\', '/');
    do {
        index = path.indexOf("/./");
        if (index != -1) {
...
StringnormalizeLocalPath(final String localPath)
Remove any trailing "\" from the end of a windows style local path.
if (localPath.endsWith("\\") && localPath.length() > 3) 
    return localPath.substring(0, localPath.length() - 1);
return localPath;