Java Path Normalize normalizePath(String path)

Here you can find the source of normalizePath(String path)

Description

normalize Path

License

Open Source License

Declaration

public static final String normalizePath(String path) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String normalizePath(String path) {
        path = path.replaceAll("\\\\", "/");
        while (path.startsWith("./"))
            path = path.substring(2);//from   w w w  .  j  av a 2  s .c  o m
        while (path.startsWith("/"))
            path = path.substring(1);
        while (path.endsWith("/."))
            path = path.substring(0, (path.length() - 2));
        int pathLength;
        do {
            pathLength = path.length();
            path = path.replaceAll("\\/\\.\\/", "/");
        } while (path.length() < pathLength);
        return path;
    }
}

Related

  1. normalizePath(String path)
  2. normalizePath(String path)
  3. normalizePath(String path)
  4. normalizePath(String path)
  5. normalizePath(String path)
  6. normalizePath(String path)
  7. normalizePath(String path)
  8. normalizePath(String path)
  9. normalizePath(String path, char sep)