Java Directory Clean cleanPath(String path)

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

Description

cleanPath static method replaces all path separators with system dependednt value.

License

Open Source License

Parameter

Parameter Description
path - string with directory/file path

Return

String path with system related path separators

Declaration

public static String cleanPath(String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**/*from   w  ww.j av a  2 s.  co m*/
     * cleanPath static method replaces all path separators with system dependednt value.
     * For UNIX it is / for Windows - "\\"
     * @param path - string with directory/file path
     * @return String path with system related path separators
     */
    public static String cleanPath(String path) {
        String str = path.replace('/', File.separatorChar);
        String final_str = str.replace('\\', File.separatorChar);
        return final_str;
    }
}

Related

  1. cleanDir(String dir)
  2. cleanDir(String directory)
  3. cleanDir(String path)
  4. cleanDirectory(File currentDir)
  5. cleanPath(String loc)
  6. cleanPaths(String root, String rel, String name)
  7. clearDir(File dir, boolean clearsubdirs)
  8. clearDir(String dirPath)