Java Path Normalize normalize(String path)

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

Description

normalize

License

Open Source License

Declaration

public static String normalize(String path) 

Method Source Code

//package com.java2s;
/**// w  ww  .  j  a  va  2 s . com
 * (C) 2011-2012 Alibaba Group Holding Limited.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 */

public class Main {
    public static final String SEPARATOR = "/";

    public static String normalize(String path) {
        String temp = path;
        if (!path.startsWith(SEPARATOR)) {
            temp = SEPARATOR + path;
        }
        if (path.endsWith(SEPARATOR)) {
            temp = temp.substring(0, temp.length() - 1);
            return normalize(temp);
        } else {
            return temp;
        }
    }
}

Related

  1. normalize(final String path)
  2. normalize(final String pathname)
  3. normalize(String path)
  4. normalize(String path)
  5. normalize(String path)
  6. normalize(String path)
  7. normalize(String path)
  8. normalize(String path)
  9. normalize(String path)