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 String normalizePath(String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String normalizePath(String path) {
        if (path == null || path.length() == 0) {
            path = "/";
        } else if (!path.startsWith("/")) {
            path = "/" + path.trim();
        } else {/*from   ww  w.  j  a  v a2  s  .c o  m*/
            path = path.trim();
        }
        if (path.length() > 1 && path.endsWith("/")) {
            path = path.substring(0, path.length() - 1);
        }
        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, char sep)
  7. normalizePath(String path, String oldFileSeperator, String newFileSeparator)
  8. normalizePath(String path, String separator)
  9. normalizePath(String pathFragment)