2、执行命令行命令
/**
* 运行命令行
* @throws Exception
*/
public synchronized static void runExecCommand(String cmdStr) throws Exception{
String osName = System.getProperty("os.name");
String cmd = "";
Process p;
try{
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
cmd = " cmd /c "+cmdStr;
Runtime.getRuntime().exec(cmd);
}else{// Linux 系统
cmd = ""+cmdStr;
String[] comands = new String[] { "/bin/sh", "-c", cmd };
p = Runtime.getRuntime().exec(comands);
}
logger.info("exec command to system:"+cmd);
}catch (Exception e) {
logger.error("io exec ee....." + e);
}finally{
//p.destroy();
}
}
3、获取本机ip
package common;
import java.net.Inet4Address;
im