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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章