Java Utililty Methods Path Create Canonical

List of utility methods to do Path Create Canonical

Description

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

Method

StringcanonicalPath(String orig)
Canonicalize a request path, making sure it starts with a slash, and getting rid of double slashes and components with the values "." or "..".
if (orig.length() == 0) {
    return "/";
if (orig.charAt(0) != '/') {
    orig = '/' + orig;
for (;;) {
    int foundAt = orig.indexOf("//");
...
Stringcanonicalpath(String path)
Convert path to: 1.
if (path == null)
    return null;
path = path.trim();
path = path.replace('\\', '/');
if (path.endsWith("/"))
    path = path.substring(0, path.length() - 1);
if (hasDriveLetter(path))
    path = path.substring(0, 1).toLowerCase() + path.substring(1);
...
StringcanonicalPath(String path)
Convert a path to a cananonical form.
if (path == null || path.length() == 0)
    return path;
int end = path.length();
int start = path.lastIndexOf('/', end);
search: while (end > 0) {
    switch (end - start) {
    case 2: 
        if (path.charAt(start + 1) != '.')
...
Stringcanonicalpath(String path, boolean relative)
Convert path to: 1.
if (path == null)
    return null;
path = path.trim();
path = path.replace('\\', '/');
if (path.endsWith("/"))
    path = path.substring(0, path.length() - 1);
if (relative && path.startsWith("/"))
    path = path.substring(1);
...