Here you can find the source of normalizePath(String _path, boolean _appendFinalSeparator)
Parameter | Description |
---|---|
_path | path |
_appendFinalSeparator | controls appendix of separator at the end |
public static String normalizePath(String _path, boolean _appendFinalSeparator)
//package com.java2s; //License from project: Open Source License public class Main { /** Character that separates components of a file path. This is "/" on UNIX and "\" on Windows. */ public static final String FILE_SEPARATOR = System.getProperty("file.separator"); /**/*www.j a v a2s . com*/ * Normalize a file system path expression for the current OS. * Replaces path separators by this OS's path separator. * Appends a final path separator if parameter is set * and if not yet present. * @param _path path * @param _appendFinalSeparator controls appendix of separator at the end * @return normalized path */ public static String normalizePath(String _path, boolean _appendFinalSeparator) { if (_path == null) { return _path; } String path = _path.replace("\\", FILE_SEPARATOR).replace("/", FILE_SEPARATOR); if (_appendFinalSeparator && !path.endsWith(FILE_SEPARATOR)) { path += FILE_SEPARATOR; } return path; } /** * Normalize a file system path expression for the current OS. * Replaces path separators by this OS's path separator. * Appends a final path separator unless present. * @param _path path * @return normalized path */ public static String normalizePath(String _path) { return normalizePath(_path, true); } }