Java Utililty Methods Unix Path

List of utility methods to do Unix Path

Description

The list of methods to do Unix Path are organized into topic(s).

Method

StringgetUNIXfilePath(String fileName)
get UNI Xfile Path
File file = new File(fileName);
return toUNIXpath(file.getAbsolutePath());
StringgetUnixRelativePath(File base, File path)
get Unix Relative Path
return base.toURI().relativize(path.toURI()).getPath().replace("\\", "/");
StringtoUNIXfilePath(String fileName)
to UNI Xfile Path
return toUNIXpath(toformatPath(fileName));
StringunixizeWindowsAbsolutePath(final String pathToCheck)
Turn absolute Windows paths into unix-friendly equivalent.
final String path;
if (pathToCheck.length() >= 1 && isKnownPathDelimiter(pathToCheck.charAt(0))) {
    path = pathToCheck.substring(1);
} else {
    path = pathToCheck;
if (path.length() >= 2 && path.charAt(1) == ':') {
    if (path.length() >= 3 && isKnownPathDelimiter(path.charAt(2))) {
...
StringunixPath(String sText)
Convert path to unix style path
if (sText == null || sText.equals(""))
    return "";
sText = replace(sText, '\\', "/");
return sText;
StringunixPathStr(String anyPath)
unix Path Str
String unixPath = anyPath.replace("\\", "/");
return (unixPath);
StringunixPathToWindows(String strPath)
unix Path To Windows
if (strPath == null || strPath.length() == 0 || OSNAME == null || !OSNAME.startsWith("Windows"))
    return strPath;
StringBuffer sbPath = new StringBuffer(strPath.trim());
String strunix = "/dev/fs/";
int nIndex = sbPath.indexOf(strunix);
int index = sbPath.indexOf("\\dev\\fs");
if (strPath.indexOf(":") != 1) {
    if (strPath.equals("/vnmr") || strPath.startsWith("/vnmr/"))
...
StringunixToUserPathName(String unixPathName)
unix To User Path Name
if (unixPathName.startsWith("~/")) {
    return "${user.home}" + unixPathName.substring(1);
} else {
    String userHome = System.getProperty("user.home");
    int len = userHome.length();
    if (unixPathName.startsWith(userHome) && unixPathName.charAt(len) == '/') {
        return "${user.home}" + unixPathName.substring(len);
    } else {
...