Distinguish between window and linux system in java

    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/";
        }
    }
	

 

Guess you like

Origin blog.csdn.net/qq_36336332/article/details/88584849