Here you can find the source of normalisePath(String path)
Parameter | Description |
---|---|
path | The path to normalize |
private static String normalisePath(String path)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww. j av a2 s . c om*/ * This normalises a path to ensure it starts with / and does not end with / * @param path The path to normalize * @return The path or an empty string if given no path */ private static String normalisePath(String path) { if (path != null) { path = path.trim(); if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } if (!path.isEmpty() && !path.startsWith("/")) { path = "/" + path; } return path; } return ""; } }