Java Path Create makePath(File cwd, String path)

Here you can find the source of makePath(File cwd, String path)

Description

make Path

License

Open Source License

Declaration

public static String makePath(File cwd, String path) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.io.File;

public class Main {
    public static String makePath(File cwd, String path) {
        String prefix = "", suffix = "";
        if (path.startsWith("jar:file:")) {
            prefix = "jar:file:";
            int exclamation = path.indexOf('!');
            suffix = path.substring(exclamation);
            path = path.substring(prefix.length(), exclamation);
        }/* w  ww .  ja  v  a2  s .  c om*/
        if (isAbsolutePath(path))
            return prefix + path + suffix;
        if (path.equals("."))
            return prefix + cwd.toString() + suffix;
        if (cwd.toString().equals("."))
            return prefix + (path.equals("") ? "." : path) + suffix;
        return prefix + new File(cwd, path).toString() + suffix;
    }

    public static boolean isAbsolutePath(String path) {
        boolean isWindows = getPlatform().startsWith("win");
        if (isWindows)
            return path.length() > 1 && path.charAt(1) == ':';
        return path.startsWith("/");
    }

    public static String getPlatform() {
        boolean is64bit = System.getProperty("os.arch", "").indexOf("64") >= 0;
        String osName = System.getProperty("os.name", "<unknown>");
        if (osName.equals("Linux"))
            return "linux" + (is64bit ? "64" : "32");
        if (osName.equals("Mac OS X"))
            return "macosx";
        if (osName.startsWith("Windows"))
            return "win" + (is64bit ? "64" : "32");
        //System.err.println("Unknown platform: " + osName);
        return osName.toLowerCase();
    }
}

Related

  1. makePath(Collection files)
  2. makePath(File copyTo)
  3. makePath(final String dir, final String... jars)
  4. makePath(String basePath)
  5. makePath(String filename, String savePath)
  6. makePath(String path1, String path2)