java执行Linux命令 .

/**
* 修改Linux目录权限
* @param path
*/ 
    public boolean chmod(String path) { 
//      LogUtil.LogCommInfo("------修改权限路劲 path="+path);  
        boolean flag   = false ; 
        try{             
            String cmdStrs[] = new String[]{"chmod","-R","775",path}; 
            Process child = Runtime.getRuntime().exec(cmdStrs); 
//          child.waitFor();  
            flag =  true ; 
        }catch(Exception e){ 
            flag =  false ; 
//          LogUtil.LogCommInfo("修改权限异常 = "+e);  
            e.printStackTrace(); 
        } 
        return flag ; 
    } 






Properties prop = System.getProperties(); String os = prop.getProperty("os.name"); System.out.println(os);os.startWith("win") || os.startWith("Win") == windows操作系统


转http://blog.csdn.net/jarvis_java/article/details/5949148

你可能感兴趣的:(java,linux)