Java Path Normalize normalizePath(String path)

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

Description

normalize Path

License

Open Source License

Declaration

private static String normalizePath(String path) 

Method Source Code

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

public class Main {
    private static int _isWindows = -1;

    private static String normalizePath(String path) {
        if (path.length() == 2 && path.charAt(1) == ':') {
            path += "/";
        }/*from ww w .  ja  v  a  2 s .c  o  m*/
        if (isWindows()) {
            path = path.replace('/', '\\');
        }
        return path;
    }

    public static boolean isWindows() {
        if (_isWindows == -1) {
            String osName = System.getProperty("os.name");
            _isWindows = osName.toLowerCase().startsWith("windows") ? 1 : 0;
        }
        return _isWindows == 1;
    }
}

Related

  1. normalizePath(String path)
  2. normalizePath(String path)
  3. normalizePath(String path)
  4. normalizePath(String path)
  5. normalizePath(String path)
  6. normalizePath(String path)
  7. normalizePath(String path)
  8. normalizePath(String path, char sep)
  9. normalizePath(String path, String oldFileSeperator, String newFileSeparator)