java中区分window与linux系统

    public static String getSystemRoot() {
        String osName = System.getProperty("os.name");
        System.out.println(osName);
        if (osName.toLowerCase().startsWith("mac")) {
            return "/usr/local/xx/";
        } else if (osName.toLowerCase().startsWith("windows")) {
            return "C:\\tiger\\xx\\";
        } else {
            return "/User/local/xx/";
        }
    }
	

猜你喜欢

转载自blog.csdn.net/qq_36336332/article/details/88584849