Here you can find the source of cleanPath(String path)
Parameter | Description |
---|---|
path | A path that could end in a slash or backslash. |
protected static synchronized String cleanPath(String path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w w w.j a v a2 s .c o m * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Removes a trailing path separator. * @param path A path that could end in a slash or backslash. * @return The same path without the trailing path separator. */ protected static synchronized String cleanPath(String path) { String slash = System.getProperty("file.separator"); if (slash != null && slash.length() > 0) { int len = path.length(); if (len > 0 && path.charAt(len - 1) == slash.charAt(0)) { return path.substring(0, len - 1); } } return path; } }