Java Path String Clean cleanPath(String path)

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

Description

Make sure the file separator is at the end of a given path.

License

Open Source License

Parameter

Parameter Description
path the path to which the file separator should be added if necessary

Return

the path ending with a file separator

Declaration

public static String cleanPath(String path) 

Method Source Code

//package com.java2s;
/*/* ww  w  .  ja  va  2 s  . c  om*/
 *  This file is part of "Tweety", a collection of Java libraries for
 *  logical aspects of artificial intelligence and knowledge representation.
 *
 *  Tweety is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Make sure the file separator is at the end of a given path.
     * @param path the path to which the file separator should be added if necessary
     * @return the path ending with a file separator
     */
    public static String cleanPath(String path) {
        if (!path.endsWith(System.getProperty("file.separator"))) {
            path = path.concat(System.getProperty("file.separator"));
        }
        return path;
    }
}

Related

  1. cleanPath(final String path)
  2. cleanPath(final String url)
  3. cleanPath(String loc)
  4. cleanPath(String path)
  5. cleanPath(String path)
  6. cleanPath(String path)
  7. cleanPath(String path)
  8. cleanPath(String path)
  9. cleanPath(String path)