Here you can find the source of normalizePath(String path)
Parameter | Description |
---|---|
path | the path to the directory or file |
public static String normalizePath(String path)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**/* ww w . ja va 2s. c om*/ * The root path of workspaces. */ public static final String WORKSPACE_ROOT = "/"; /** * Normalizes a path by removing trailing slash, unless the path is the root path. * * @param path the path to the directory or file */ public static String normalizePath(String path) { if (WORKSPACE_ROOT.equals(path)) { return path; } if (path.isEmpty()) { return WORKSPACE_ROOT; } int maybeSlash = path.length() - 1; return path.charAt(maybeSlash) == '/' ? path.substring(0, maybeSlash) : path; } }