1.Java调用shell
public Process exec(String command) throws IOException
public Process exec(String command,String[] envp) throwsIOException
public Process exec(String command,String[] envp,File dir) throwsIOException
public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throwsIOException
public Process exec(String[] cmdarray, String[] envp,File dir)throws IOException
1)执行简单的命令的方法:
代码如下:
2)执行带有参数的命令(尤其是参数需要用引号的)时则需要用String的数组来表示整个命令,而且要用转义符把引号的特殊含义去除,例如我们要执行find / -name "*mysql*" -print 时,用如下代码